Installation
npm install cryptorjs --save
Example
Basic
var cryptorjs = ; var myCryptor = 'yourSecretKey'; var encoded = myCryptor;// => '37d8e07a3dddc2971f3e53b1021f51' var decoded = myCryptor;// => 'myExampleString'
Object encryption
var cryptorjs = ; var myCryptor = 'yourSecretKey'; var encoded = myCryptor;// => '2183c42066819ed9184f1df116' var decoded = myCryptor;// => { a: 1, b: 2 }
With a cipher
For example using "camellia-256-cfb1" cipher
var cryptorjs = ; var myCryptor = 'yourSecretKey' 'camellia-256-cfb1'; var encoded = myCryptor;// => 'ac3277ba5c3f433d6b7ea70979fe55' var decoded = myCryptor;// => 'myExampleString'
Ciphers
You can get the list with a static method
var cryptorjs = ; cryptorjs; /*=> [ 'aes-128-cbc', 'aes-128-cbc-hmac-sha1', 'aes-128-cbc-hmac-sha256', 'aes-128-ccm', 'aes-128-cfb', 'aes-128-cfb1', 'aes-128-cfb8',...] */
Hash helpers
Create an hash using available hashes in your platform
var cryptorjs = ; // Check if exists MD5 hashconsole; //=> true cryptorjshash'ciao' 'md5'; /*=> '6e6bc4e49dd477ebc98ef4046c067b5f'*/ cryptorjshash'ciao' 'sha1'; /*=> '1e4e888ac66f8dd41e00c5a7ac36a32a9950d271'*/
Supported ciphers (since 3.0.0)
- aes-256-cbc
- aes-256-cbc-hmac-sha1
- aes-256-cbc-hmac-sha256
- aes-256-cfb
- aes-256-cfb1
- aes-256-cfb8
- aes-256-ctr
- aes-256-ofb
- aes256
- camellia-256-cbc
- camellia-256-cfb
- camellia-256-cfb1
- camellia-256-cfb8
- camellia-256-ofb
- camellia256
License
Cryptorjs is open-sourced software licensed under the MIT license