Skip to content

Instantly share code, notes, and snippets.

View jack3898's full-sized avatar

Jack Wright jack3898

View GitHub Profile
@chris-rock
chris-rock / crypto-buffer.js
Last active January 28, 2025 02:50
Encrypt and decrypt buffers in nodejs
// Part of https://github.com/chris-rock/node-crypto-examples
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
function encrypt(buffer){
var cipher = crypto.createCipher(algorithm,password)
var crypted = Buffer.concat([cipher.update(buffer),cipher.final()]);
return crypted;