On Tuesday, July 16, 2013 6:06:49 PM UTC-4, James Coglan wrote:
>
> Here's a more concise expression of the problem: these two programs
> produce different outputs. I need to fix the Node program so it does the
> same thing as the Ruby one:
>
> https://gist.github.com/jcoglan/6015439
>
The problem is you're using the wrong cipher creation method in node. You
want crypto.createDecipheriv().
Since the default IV for non-ECB (and you really should *not* be using ECB)
ciphers in Ruby is all nulls/zeroes, you need to supply this to
createDecipheriv like so:
var crypto = require('crypto');
var message = 'ZsHUBYxu9tNHB3sOpT7ICQ==',
key = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
cipher = crypto.createDecipheriv('aes-256-cbc', key,
'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0');
console.log(cipher.update(message, 'base64', 'utf8') +
cipher.final('utf8'));
// outputs: yolo
Although you should also really use a better IV too :-)
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.