Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
easy-nodecrypt
Advanced tools
A simple nodejs library that makes life easier when you want to encrypt and decrypt string to multiple encodings.
A simple nodejs library that makes life easier when you want to encrypt and decrypt string to multiple encodings.
This library was written in pure NodeJS with TypeScript.
With IV
Create a new instance of NodeCryptIV
const NodeCryptIV = require('easy-nodecrypt').NodeCryptIV;
Random mode
const nodeCryptIV = new NodeCryptIV({ secret: 'mysecret' });
const encrypted = nodeCryptIV.encrypt('Pika Pika!').toBase64();
console.log(encrypted); // emlSWvnh7cUwkEvWWeZafcR3Kp8YJafoRoJvJBQ_t38
const decrypted = nodeCryptIV.decrypt(encrypted);
console.log(decrypted); // Pika Pika!
No random mode
You can give the IV with an environment variable (NODECRYPT_IV) or directly in the NodeCryptIV instance. The function use first the IV in parameter and if it's not exist, it use the environment variable.
The IV must have a length of 16 characters.
const nodeCryptIV = new NodeCryptIV({ secret: 'mysecret', iv: 'totototototototo' });
const encrypted = nodeCryptIV.encrypt('Pika Pika!').toBase64();
console.log(encrypted); // dG90b3RvdG90b3RvdG90b8bCKJ7SMuOaSWvijqvujXM
const decrypted = nodeCryptIV.decrypt(encrypted);
console.log(decrypted); // Pika Pika!
Without IV
Create a new instance of NodeCrypt
const NodeCrypt = require('easy-nodecrypt').NodeCrypt;
const nodeCrypt = new NodeCrypt('mysecret');
const encrypted = nodeCrypt.encrypt('Pika Pika!').toBase64();
console.log(encrypted); // spsAgpAHVSClkOKb0LTT8Q
const decrypted = nodeCrypt.decrypt(encrypted);
console.log(decrypted); // Pika Pika!
// Encrypt value.
const nodeCrypt = new NodeCrypt('mysecret');
const encrypted = nodeCrypt.encrypt('Pika Pika!').toBase64();
// Decrypt value with the same instance.
const decrypted = nodeCrypt.decrypt(encrypted);
// Decrypt value with another instance.
const newInstance = new NodeCrypt('mysecret');
// Specify the encoding of the encrypted text.
newInstance.encoding = 'base64';
newInstance.decrypt(encrypted);
You can give the above values by environements variables:
Environement variable | Code variable | Class |
---|---|---|
NODECRYPT_SECRET | secret | NodeCrypt, NodeCryptIV |
NODECRYPT_IV | iv | NodeCryptIV |
Guillaume Quittet
https://www.linkedin.com/in/gquittet/
FAQs
A simple nodejs library that makes life easier when you want to encrypt and decrypt string to multiple encodings.
We found that easy-nodecrypt 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.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.