Installation
npm install cryptorjs --save
Example
Basic
var cryptorjs = require('cryptorjs');
var myCryptor = new cryptorjs('yourSecretKey');
var encoded = myCryptor.encode('myExampleString');
var decoded = myCryptor.decode('37d8e07a3dddc2971f3e53b1021f51');
Object encryption
var cryptorjs = require('cryptorjs');
var myCryptor = new cryptorjs('yourSecretKey');
var encoded = myCryptor.encode({ a: 1, b: 2 });
var decoded = myCryptor.decode('2183c42066819ed9184f1df116');
With a cipher
For example using "camellia-256-cfb1" cipher
var cryptorjs = require('cryptorjs');
var myCryptor = new cryptorjs('yourSecretKey', 'camellia-256-cfb1');
var encoded = myCryptor.encode('myExampleString');
var decoded = myCryptor.decode('ac3277ba5c3f433d6b7ea70979fe55');
Ciphers
You can get the list with a static method
var cryptorjs = require('cryptorjs');
cryptorjs.getCiphers();
Hash helpers
Create an hash using available hashes in your platform
var cryptorjs = require('cryptorjs');
console.log(cryptorjs.hasHash('md5'));
cryptorjs.hash('ciao', 'md5');
cryptorjs.hash('ciao', 'sha1');
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
Author
Fabio Ricali