Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Apr 1, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant