Hi,

As usual, the thing to do in these cases is to get a very small example
working and then extend it to match your full  /  final use case.

I don't know the python crypto stuff and it's not obvious from the snippet
you posted which AES/ECB cipher you are using.   This could be the source
of your problems.
See :
crypto.getCiphers()
Returns an array with the names of the supported ciphers.

--
Anyway, here is a short example using aes-128-ecb  and your key :
---- Encode :
var cipherType = "aes-128-ecb";
var cipherKey  = "9kL8yb/3Tu2czOr5qfiGPgJmx25s+T15";

var ecb = new Buffer("hello there");
var cipher = crypto.createCipher(cipherType, cipherKey);var t = [];
cipher.setAutoPadding(true);t.push(cipher.update(ecb, "ascii", "hex"))
t.push(cipher.final("hex"));
console.log(t.join(''));
-----Decode :
var fs = require('fs'),
        crypto = require('crypto');

var cipherType = "aes-128-ecb";
var cipherKey  = "9kL8yb/3Tu2czOr5qfiGPgJmx25s+T15";
var ecb = fs.readFileSync("./encrypted.txt", "ascii").trim();
var decipher = crypto.createDecipher(cipherType, cipherKey);

var t = [];
t.push(decipher.update(ecb, "hex", "ascii"));
t.push(decipher.final("ascii"));

console.log(t.join(''));
----
$ node ./s_enc.js
710c90af43621e6c9b6d7da36d2c17f1
$ node ./s_enc.js > encrypted.txt
$ node ./s_dec.js
hello there

- Kelsey




On Tue, Jul 2, 2013 at 4:18 PM, Jonny_Flowers <
[email protected]> wrote:

> Hi,
> I have some decryption code in python that I need ported to node.  I
> cannot seem to get the decryption right and I am going crazy.
>
> My python code is:
>
>
>
> from Crypto.Cipher import AES
> mode = AES.MODE_ECB
> secret = "9kL8yb/3Tu2czOr5qfiGPgJmx25s+T15"
> cipher = AES.new(secret, mode)
> DecodeAES = lambda c, e: c.decrypt(e.decode("hex"))
> pre_add = DecodeAES(cipher, incoming)
>
> I need to somehow get the exact same thing working from node.js
>
> Please help I am getting desperate.
>
> Many thanks
> Jonny
>
> --
> --
> 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.
>
>
>

-- 
-- 
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.


Reply via email to