Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
MCrypt compatible crypto wrapper for Node.js
npm install --save cryptian
yarn add cryptian
Check out the test folder to find out the different ways to use it.
const fs = require('fs');
const {algorithm, mode, padding, createEncryptStream} = require('cryptian');
const key = Buffer.from('0a0c0e1012141618', 'hex');
const iv = Buffer.from('ca40f5af0b1aeea2', 'hex');
const des = new algorithm.Des();
const cipher = new mode.cbc.Cipher(des, iv);
const transform = createEncryptStream(cipher, padding.Pkcs5);
fs.readFile('test.png')
.pipe(createEncryptStream(cipher, padding.Pkcs5))
.pipe(fs.writeFile('test.png.encrypted'));
const fs = require('fs');
const {algorithm, mode, padding, createDecryptStream} = require('cryptian');
const key = Buffer.from('0a0c0e1012141618', 'hex');
const iv = Buffer.from('ca40f5af0b1aeea2', 'hex');
const des = new algorithm.Des();
const cipher = new mode.cbc.Decipher(des, iv);
const transform = createEncryptStream(cipher, padding.Pkcs5);
fs.readFile('test.png.encrypted')
.pipe(createDecryptStream(cipher, padding.Pkcs5))
.pipe(fs.writeFile('test.png'));
All the following crypto algorithms ported from libmcrypt
const assert = require('assert');
const {algorithm} = require('cryptian');
const des = new algorithm.Des();
set.setKey(Buffer.from('0a0c0e1012141618', 'hex'));
const ciphertext = Buffer.from('a1502d70ba1320c8', 'hex');
const plaintext = Buffer.from('0001020304050607', 'hex');
assert(ciphertext.equals(des.encrypt(plaintext)), 'encrypted plaintext should equal to ciphertext');
assert(plaintext.equals(des.decrypt(ciphertext)), 'decrypted ciphertext should equal to plaintext');
const assert = require('assert');
const {algorithm} = require('cryptian');
const enigma = new algorithm.Enigma();
enigma.setKey(Buffer.from('enadyotr', 'ascii'));
const ciphertext = Buffer.from('f3edda7da20f8975884600f014d32c7a08e59d7b', 'hex');
const plaintext = Buffer.from('000102030405060708090a0b0c0d0e0f10111213', 'hex');
assert(ciphertext.equals(enigma.encrypt(plaintext)), 'encrypted plaintext should equal to ciphertext');
assert(plaintext.equals(enigma.decrypt(ciphertext)), 'decrypted ciphertext should equal to plaintext');
All the following block cipher mode algorithms ported from libmcrypt
const assert = require('assert');
const {algorithm, mode} = require('cryptian');
const plaintext = Buffer.from('88cc3d134aee5660f7623cf475fe9df20f773180bd70b0ef2aae00910ba087a1', 'hex');
const ciphertext = Buffer.from('ace98b99e6803c445b8bb76d937ea1b654fc86ed2e0e11597e52867c25ae96f8', 'hex');
const iv = Buffer.from('2425b68aac6e6a24', 'hex');
// don't use Dummy algorithm in real production environment
// because this is not an encryption algorithm
const dummy = new algorithm.Dummy();
const cipher = new mode.cbc.Cipher(dummy, iv);
assert(ciphertext.equals(cipher.transform(plaintext)), 'transformed plaintext should be equal to ciphertext');
const decipher = new mode.cbc.Decipher(dummy, iv);
assert(plaintext.equals(decipher.transform(ciphertext)), 'transformed ciphertext should be equal to plaintext');
const assert = require('assert');
const {padding} = require('cryptian');
const padder = new padding.Pkcs5(8);
const padded = Buffer.from('0575ba559d030303', 'hex');
const unpadded = Buffer.from('0575ba559d', 'hex');
assert(padded.equals(padder.pad(unpadded)));
assert(unpadded.equals(padder.unpad(padded)));
FAQs
Crypto suite
The npm package cryptian receives a total of 248 weekly downloads. As such, cryptian popularity was classified as not popular.
We found that cryptian demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.