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

DES and 3DES work only on alphabets #128

Open
GoogleCodeExporter opened this issue Mar 15, 2015 · 0 comments
Open

DES and 3DES work only on alphabets #128

GoogleCodeExporter opened this issue Mar 15, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Please use this code to produce this bug. I am trying to encrypt from PHP and 
decryption in Javascript.

PHP
function encryptByDES($plain_text,$key){
            return base64_encode(mcrypt_encrypt(MCRYPT_3DES, $key, $plain_text, MCRYPT_MODE_ECB));
        }

echo encryptByDES(json_encode(new array('type'=>'error','message'=>'Invalid 
Number. Please try another number')),'fecb4521');

JAVASCRIPT
function decryptByDES(ciphertext, key) {
var keyHex = CryptoJS.enc.Utf8.parse(key);

// direct decrypt ciphertext
var decrypted = CryptoJS.DES.decrypt({
    ciphertext: CryptoJS.enc.Base64.parse(ciphertext)
}, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});

return decrypted.toString(CryptoJS.enc.Utf8);
}

alert(decryptByDES('<output from PHP FUNCTION ABOVE>','fecb4521'));


Original issue reported on code.google.com by haris.ah...@gmail.com on 18 Apr 2014 at 11:34

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