Giter Site home page Giter Site logo

veliovgroup / meteor-aes-crypto Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 20 KB

๐Ÿ” Simplified isomorphic API for AES cipher by CryptoJS

Home Page: https://atmospherejs.com/ostrio/aes-crypto

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%
meteor meteorjs aes-cipher cryptojs aes meteor-package

meteor-aes-crypto's Introduction

Isomorphic AES cipher

Simplified isomorphic API for AES cipher by CryptoJS.

This implementation uses a random salt for every encrypted value and CFB padding. This means if you even encrypt two times the same value with the same password the encrypted result will be both times different. So encrypted values by this method are strong against rainbow tables and all other precomputed tables.

  • ๐Ÿ˜Ž No external dependencies;
  • ใŠ—๏ธ Has Unicode, Cyrillic, emoji support for values and keys;
  • ๐Ÿ‘ทโ€โ™‚๏ธ 100% tests coverage.

Installation

meteor add ostrio:aes-crypto

ES6 Import

import { AESencrypt, AESdecrypt } from 'meteor/ostrio:aes-crypto';

API

Encrypt

  • AESencrypt(value, password)
    • value {String}
    • password {String}
AESencrypt('My Plain String', 'TXkgUGxhaW4gU3RyaW5n');
// Returns: '{"ct":"ZQAp/MEV0pMDn6V7oY5YFVvEGNxvG2eJliNPZpT9U2I=","iv":"0e472d2cd20892ac9cfcf91dea4fe98e","s":"35e808ccc71b8c13"}'

Decrypt

  • AESdecrypt(value, password)
    • value {String} - In form of JSONableString
    • password {String}
AESdecrypt('{"ct":"ZQAp/MEV0pMDn6V7oY5YFVvEGNxvG2eJliNPZpT9U2I=","iv":"0e472d2cd20892ac9cfcf91dea4fe98e","s":"35e808ccc71b8c13"}', 'TXkgUGxhaW4gU3RyaW5n');
// Returns: 'My Plain String'

Validate encrypted JSONable String

To validate returned object from AESencrypt function use this regular expression:

/^{"ct":"([A-Za-z0-9+\/]+(\={0,2}))","iv":"([0-9a-f]{32})","s"\:"([0-9a-f]{16})"}$/;

Example:

const JSONableString = AESencrypt('My Plain String', 'TXkgUGxhaW4gU3RyaW5n');
/^{"ct":"([A-Za-z0-9+\/]+(\={0,2}))","iv":"([0-9a-f]{32})","s"\:"([0-9a-f]{16})"}$/.test(JSONableString);
// Returns: true

AESdecrypt(JSONableString, 'TXkgUGxhaW4gU3RyaW5n');
// Returns: 'My Plain String'

meteor-aes-crypto's People

Contributors

dr-dimitru avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.