GithubHelp home page GithubHelp logo

cryptor's Introduction

Cryptorjs

Simple library for encryption and decryption of string, number and object using a key

Installation

npm install cryptorjs --save

Example

Basic

var cryptorjs = require('cryptorjs');

var myCryptor = new cryptorjs('yourSecretKey');

var encoded = myCryptor.encode('myExampleString');
// => '37d8e07a3dddc2971f3e53b1021f51'

var decoded = myCryptor.decode('37d8e07a3dddc2971f3e53b1021f51');
// => 'myExampleString'

Object encryption

var cryptorjs = require('cryptorjs');

var myCryptor = new cryptorjs('yourSecretKey');

var encoded = myCryptor.encode({ a: 1, b: 2 });
// => '2183c42066819ed9184f1df116'

var decoded = myCryptor.decode('2183c42066819ed9184f1df116');
// => { a: 1, b: 2 }

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');
// => 'ac3277ba5c3f433d6b7ea70979fe55'

var decoded = myCryptor.decode('ac3277ba5c3f433d6b7ea70979fe55');
// => 'myExampleString'

Ciphers

You can get the list with a static method

var cryptorjs = require('cryptorjs');

cryptorjs.getCiphers();

/*=> [ '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 = require('cryptorjs');

// Check if exists MD5 hash
console.log(cryptorjs.hasHash('md5')); //=> true

cryptorjs.hash('ciao', 'md5');

/*=> '6e6bc4e49dd477ebc98ef4046c067b5f'*/

cryptorjs.hash('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

Author

Fabio Ricali

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.