Created
February 14, 2011 03:20
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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