Socket
Socket
Sign inDemoInstall

easycrypt

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easycrypt

A simple bi-directional salting and encryption system designed for securing authentication tokens.


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

EasyCrypt

A simple bi-directional salting and encryption system designed for securing authentication tokens.

"use strict";

const EasyCrypt = require("../EasyCrypt.js");
const ez = new EasyCrypt();

let stringToEncrypt = "This is easy.";
let crypted = ez.encrypt(stringToEncrypt);
console.log(`Crypted: ${crypted.content}`);
console.log(`Decrypted: ${ez.decrypt(crypted)}`);

Installing

npm install easycrypt

API

EasyCrypt

Main class, constructor has no arguments and returns a EasyCrypt object.

Settings
Environment Variable

The encryption password is stored on an environment variable called EasyCryptPW.

You must set the environment variable before using EasyCrypt.

From the command line:

EasyCryptPW='3zTvzr3p67VC61jmV54rIYu1545x4TlY' node EasyCrypt.js 
Construction
const EasyCrypt = require("../EasyCrypt.js");
const ez        = new EasyCrypt();
Methods
encrypt

Used to salt an encrypt a piece of text.

const EasyCrypt = require("../EasyCrypt.js");
const ez        = new EasyCrypt(/\S+/g);
const text      = ez.encrypt("Easy");
console.log(text);

/* 
 * { content: '5cc07dd95c919de9544ed4f1f5+H9StNlQK',
 * tag: <Buffer 97 78 be 76 66 da 3c 71 ca fd 4e a0 07 d0 39 f8> }
*/

// This same object must be passed to decrypt, so store content and tag

Returns object with authorization buffer and encrypted content.

decrypt

Used to salt an encrypt a piece of text.

const EasyCrypt = require("../EasyCrypt.js");
const ez        = new EasyCrypt(/\S+/g);
const text      = ez.encrypt("Easy");
console.log(ez.decrypt(text)); // Easy

Returns the original decrypted string.

Scripts

Testing

To run mocha/chai tests. npm run test

Examples

To run the main example. npm run ex

License

EasyCrypt.js is released under the MIT license.

Keywords

FAQs

Package last updated on 20 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc