Skip to content

Instantly share code, notes, and snippets.

@keks
Created February 14, 2011 03:20
Show Gist options
  • Save keks/825438 to your computer and use it in GitHub Desktop.
Save keks/825438 to your computer and use it in GitHub Desktop.
the resulting file could not be opened by feh, ImageMagick and xnview. Try for yourself.
var crypto = require('crypto');
var fs = require('fs');
fs.readFile('/tmp/4.jpg', function(err, data){
if (!err){
var cipher = crypto.createCipher('aes-256-cbc','abc') // set up cipher engine
var crypted = cipher.update(data,'binary','hex')
crypted += cipher.final('hex')
var decipher = crypto.createDecipher('aes-256-cbc','abc') //set up decipher engine
var dec = decipher.update(crypted,'hex','binary')
dec += decipher.final('binary')
fs.writeFile('/tmp/5.jpg', dec); //write deciphered data
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment