Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mvayngrib/react-native-aes
aes encryption/decryption in react native
https://github.com/mvayngrib/react-native-aes
Last synced: about 2 months ago
JSON representation
aes encryption/decryption in react native
- Host: GitHub
- URL: https://github.com/mvayngrib/react-native-aes
- Owner: mvayngrib
- License: mit
- Created: 2015-12-17T16:24:20.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-17T16:42:53.000Z (almost 9 years ago)
- Last Synced: 2024-10-11T09:03:51.626Z (2 months ago)
- Language: Objective-C
- Size: 16.6 KB
- Stars: 29
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-native - react-native-aes ★24 - AES in react-native (Components / Utils & Infra)
- awesome-react-native - react-native-aes ★24 - AES in react-native (Components / Utils & Infra)
- awesome-react-native - react-native-aes ★24 - AES in react-native (Components / Utils & Infra)
- awesome-react-native-ui - react-native-aes ★15 - AES in react-native (Components / Utils & Infra)
- awesome-react-native - react-native-aes ★24 - AES in react-native (Components / Utils & Infra)
README
# react-native-aes
AES encryption/decryption in react native
## Supported Ciphers
* AES-256-CBC
## Usage
```js
var AES = require('react-native-aes')
var Buffer = require('buffer').Buffervar stringInput = 'hey ho'
var bufferInput = new Buffer(stringInput)
// sample key
var key = new Buffer('f0ki13SQeRpLQrqk73UxhBAI7vd35FgYrNkVybgBIxc=', 'base64')
var cipherName = 'AES-256-CBC'
AES.encryptWithCipher(
cipherName, // String
bufferInput, // Buffer (input data)
key, // AES key, e.g. 32 bytes of random data
function (err, encrypted) {
// "encrypted" is of the form
// {
// ciphertext: Buffer,
// iv: Buffer
// }
//
// you'll need both parts to decryptAES.decryptWithCipher(
cipherName, // String
encrypted.ciphertext, // Buffer (input data)
key,
encrypted.iv, // Buffer
function (err, plaintext) {
// plaintext is a Buffer
if (plaintext.toString() !== stringInput) {
throw new Error('time to report an issue!')
}
}
)
}
)
```