Open GoogleCodeExporter opened 9 years ago
Well, never mind and thanks anyway... I gave up on crypto-js, and went back to
Node.js's built-in crypto library (which I gave up on previously because I
mistakenly thought it wouldn't handle CFB, but it does).
Perhaps you'll want to answer my query anyway, in case it helps some of your
other users in the future. (Besides, I'd like to see how close I was to
getting this to work with your library.)
But for those who are stuck like I was, and get here via a search, here is my
Node.js-crypto-based (repeat, NOT crypto-js-based!) code. It decrypts its own
encryptions, as well as the ones from my Java server. (Whew.)
sharedSecret = '<hex shared secret here>'
_encrypt: (string) ->
randomIV = @_generateRandomHexString 16
cipher = crypto.createCipheriv 'des-ede3-cfb', new Buffer(sharedSecret, 'hex'), new Buffer(randomIV, 'hex')
randomIV + cipher.update(string, 'utf8', 'hex') + cipher.final('hex')
_decrypt: (encrypted) ->
hexStringArray = encrypted.split ''
iv = hexStringArray[0..15].join('')
ciphertext = hexStringArray[16..].join('')
decipher = crypto.createDecipheriv 'des-ede3-cfb', new Buffer(sharedSecret, 'hex'), new Buffer(iv, 'hex')
decipher.update(ciphertext, 'hex', 'utf8') + decipher.final('utf8')
Thanks,
Ed
Original comment by ed.tram...@gmail.com
on 10 Feb 2014 at 11:22
Original issue reported on code.google.com by
ed.tram...@gmail.com
on 10 Feb 2014 at 5:17