Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
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();
des.setKey(key);
const cipher = new mode.cbc.Cipher(des, iv);
fs.createReadStream('test.png')
.pipe(createEncryptStream(cipher, padding.Pkcs5))
.pipe(fs.createWriteStream('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();
des.setKey(key);
const cipher = new mode.cbc.Decipher(des, iv);
fs.createReadStream('test.png.encrypted')
.pipe(createDecryptStream(cipher, padding.Pkcs5))
.pipe(fs.createWriteStream('test-decrypted.png'));
All the following crypto algorithms ported from libmcrypt
const assert = require('assert');
const {algorithm} = require('cryptian');
const des = new algorithm.Des();
des.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 144 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.