# cryptoaes

> Cross Platform Encryption - Decryption with AES ( SHA-256 )

Latest version **1.0.3** (published 2016-08-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install cryptoaes
pnpm add cryptoaes
yarn add cryptoaes
bun add cryptoaes
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2016-08-26 |
| First published | 2016-08-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Alper Tayfun |
| Maintainers | alpertayfun |
| Keywords | crypto , cross , platform , android , ios , mobile |

## Links

- npm: https://www.npmjs.com/package/cryptoaes
- Repository: https://github.com/alpertayfun/crypto-aes
- Homepage: https://github.com/alpertayfun/crypto-aes#readme
- Issues: https://github.com/alpertayfun/crypto-aes/issues
- npm.io page: https://npm.io/package/cryptoaes

## Dependencies (1)

- [crypto-js](https://npm.io/package/crypto-js.md) ^3.1.6

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2016-08-26
- 1.0.2 — 2016-08-26
- 1.0.1 — 2016-08-26
- 1.0.0 — 2016-08-26

## README

# ﻿Crypto-Aes
--------


### Cross Platform SHA-256 bit AES Encryption - Decryption


Project contains the implementation SHA-256 bit AES encryption which works on stated platforms only. Easy use and implementation.


Platforms:

- iOS ( not tested yet)

- Android

- Windows (C#). ( not tested yet )

- Node.js

- Web

## Android Side

Just added Crypto.java file into your project and then add these functions.


### Usage

```
//debug mode on
Crypto.DEBUG_LOG_ENABLED = true;

//key string must be max 32 char
String key = "0k8j7h6g5f4d3s2ak8j7h6g5f4d3s2a";

//iv string must be max 16 char
String iv = "0k8j7h6g5f4d3s2a";

//message string must be utf-8
String message = "hello world!!!";

//ecnrypted string
String encrypted = Crypto.encrypts(message,key,iv);

Log.d("Crypto",encrypted);

//decrypted string
String decrypted = Crypto.decrypts(encrypted,key,iv);

Log.d("Crypto",decrypted);
```


## Web Side

Must be included cryptojs.js file into your project.

### Functions

```
function getBytes(e){
  var bytes = [];
  for (var i = 0; i < e.length; ++i) {
    bytes.push(e.charCodeAt(i));
  }
  return bytes;
}

function getHex(e){
  return e.map(function(byte) {
    return ('0' + (byte & 0xFF).toString(16)).slice(-2);
  }).join('');
}

function hash(e){
  return CryptoJS.SHA256(e);
}
```

### Usage

```
var message = "hello world!!!";
var iv = "0k8j7h6g5f4d3s2a";
var key = "0k8j7h6g5f4d3s2ak8j7h6g5f4d3s2a";


var iv1 = CryptoJS.enc.Hex.parse(getHex(getBytes(iv)));

console.log(iv1);

var cipher = CryptoJS.AES.encrypt(message, hash(key), {
    iv: iv1,
    mode: CryptoJS.mode.CBC,
    keySize: 256 / 32,
    padding: CryptoJS.pad.Pkcs7
});


var encrypted64 = cipher.ciphertext.toString(CryptoJS.enc.Base64);
console.log(encrypted64);

//decrypt
var bytes  = CryptoJS.AES.decrypt(encrypted64.toString(), hash(key), {
      iv: iv1,
      mode: CryptoJS.mode.CBC,
      keySize: 256 / 32,
      padding: CryptoJS.pad.Pkcs7
});

var plaintext = bytes.toString(CryptoJS.enc.Utf8);

console.log(plaintext);
```

## Node.js Side

npm install cryptoaes

### Usage

```
var Crypto = require("cryptoaes");

var message = "hello world!!!";
var iv = "0k8j7h6g5f4d3s2a";
var key = "0k8j7h6g5f4d3s2ak8j7h6g5f4d3s2a";

var r = Crypto.encrypts(message,key,iv);
console.log(r);
var r = Crypto.decrypts(r,key,iv);
console.log(r);
```

Do you want to donate ?

[![Support on Gratipay](https://img.shields.io/gratipay/alpertayfun.svg)](https://gratipay.com/~alpertayfun/)

---
_Source: https://npm.io/package/cryptoaes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
