Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
A simple bi-directional salting and encryption system designed for securing authentication tokens.
A simple bi-directional salting and encryption system designed for securing authentication tokens.
const { ezEncrypt, ezDecrypt } = require("easycrypt");
let stringToEncrypt = "This is easy.";
let crypted = ezEncrypt(stringToEncrypt);
console.log(`Crypted: ${crypted}`);
console.log(`Decrypted: ${ezDecrypt(crypted)}`); // This is easy.3@af2@F#Sd
const { ezDecrypt } = require("easycrypt");
const encryptedString = database.getEncryptedString(); // get encrypted string
const userInput = api.getUserInput(); // get user supplied string to compare to
const salt = encryptedString.split(':');
const decrypt = ezDecrypt(encryptedString);
return `${userInput}${salt}` === decrypt;
const { ezCompare } = require("easycrypt");
const input = 'Easy';
const crypted = ezEncrypt(input);
return ezCompare(input, crypted);
npm install easycrypt
Require exports ezEncrpyt, ezDecrypt and ezCompare.
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
Used to salt and encrypt a piece of text.
const { ezEncrypt } = require("easycrypt");
const text = ezEncrypt("Easy");
console.log(text);
// x8PNf3Oq/NC/0+wAEvIaYw==:]RYY9)g6MdD@:daGjLpCvnJJy4s95XpNJ7w==:8LC)7$"'MQY)
// This same string must be passed to decrypt so store it
Returns an encryption string with four parts separated by colons.
Used to decrypt a string encrypted with ezEnrypt.
const { ezEncrypt, ezDecrypt } = require("easycrypt");
const crypt = ezEncrypt("Easy");
console.log(ezDecrypt(crypt));
Returns the original decrypted string with the salt appended to the end.
Performs secure compare. Takes a user input and a previous encryption string returned from ezEncrypt. It then encrypts the user input with the same salt and iv from the encryption string and compares. The original encrypted string is never decrypted.
const { ezEncrypt, ezCompare } = require("easycrypt");
const crypt = ezEncrypt("Easy");
console.log(ezCompare("Easy", crypt));
To run mocha/chai tests.
npm run test
To run the main example.
npm run ex
EasyCrypt.js is released under the MIT license.
FAQs
A simple bi-directional salting and encryption system designed for securing authentication tokens.
The npm package easycrypt receives a total of 1 weekly downloads. As such, easycrypt popularity was classified as not popular.
We found that easycrypt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.