arshanmugam / crypto-js

Automatically exported from code.google.com/p/crypto-js
0 stars 0 forks source link

TripleDES result is different each time, and is not correct #141

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi everyone,

Here's my story, I need to send an authentification string encrypted in 
TripleDES (ECB, Pkcs5 pad) to a Java server which will decrypt it, but I don't 
have a hand on it. I just have the information if the auth was successful or not

message = 'abcdefghijklmnopqrstuvwxyz';
key = '12345678';

I tried in PHP which was successful (I attached the PHP file)
i gives me this result with mcrypt_encrypt("tripledes", $key, 
pkcs5_pad($message), "ecb", '');
”ÔCkõ¶“»›9ˆ·¿P‘ÚÐRFÕ¶ˆ¬ ,$¡æð
and after a bin2hex
94D4436BC3B5B693BB9B3988B7BF085091DAD0524605D5B688AC0D2C24A1E6F0

But when using CryptoJS, It gives different output everytime, and not the same 
result
<script src="library/ext/CryptoJS v3.1.2/rollups/tripledes.js"></script>
<script src="library/ext/CryptoJS v3.1.2/components/mode-ecb.js"></script>
var message     = 'abcdefghijklmnopqrstuvwxyz';
var key = '12345678';
var encryptedData   = CryptoJS.TripleDES.encrypt(message, key, { mode: 
CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });

// result = U2FsdGVkX1/NqhCXJljnsedaLfxqPsQlZUKygTpzU8TGeHefHEL7ie+e3EgTbV66

but it gives diffenret ouput everytime I reload the page, just the beginning is 
constant U2FsdGVkX1

I can't find why, and how can I get to the same result.

After searching for days (and my superior starting to question me) I can't find 
the reason why. And As you can tell cryptography is really not my forte.

Thanks in advance.

Original issue reported on code.google.com by PioDeCit...@gmail.com on 15 Sep 2014 at 1:04

Attachments: