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

decrypt a message encrypted in php #61

Open
smart--petea opened this issue Jan 5, 2017 · 4 comments
Open

decrypt a message encrypted in php #61

smart--petea opened this issue Jan 5, 2017 · 4 comments

Comments

@smart--petea
Copy link

Hi. I have an Yii application using "rijndael-128", "ofb" with IV. The encrypted message is saved in mysql and read in a node.js application. I try to decrypt it. The message is stored in mysql as blob and node-mysql transform it in a Buffer. I do not change it. My algorithm is

let message = ....; //Buffer
let Decipher = new MCrypt("rijndael-128", "ofb");
let ivSize = Decipher.getIvSize();
let iv = message.slice(0, ivSize); //IV
Decipher.open(encryptionKey, iv); //encryptionKey is considered as password on Yii side
console.log(Decipher.decypher(message.slice(ivSize)); //decyper only the encrypted part, without IV
//the result printed by console.log is = "correct message" + "garbage"

How could I get rid of the garbage from the decrypted message?

Thank you

@tugrul
Copy link
Owner

tugrul commented Jan 10, 2017

Can you create test case using test data with test keys by Yii application and pull request like following javascripts:

https://github.com/tugrul/node-mcrypt/tree/master/test

you able to run tests using npm test command

I'm going to inspect error detail with this

@misterfresh
Copy link

I'm also having issues trying to decode a prestashop cookie with MCrypt("rijndael-128", "cbc").
The first couple characters of the message are replaced with garbage, the rest of the message is decrypted fine, but there are no errors. I'll try to see if I can reproduce it with dockerfiles.

@misterfresh
Copy link

When I make "var_dump" in the php file, I get as cookie contents :
date_add|2017-04-27 23:30:25¤id_lang|1¤id_currency|1¤id_guest|571369¤id_connections|590882¤checksum|2523349829

but with node-mcrypt I get:
����Ӱy����J" R�-27 23:30:25¤id_lang|1¤id_currency|1¤id_guest|571369¤id_connections|590882¤checksum|2523349829

@tugrul
Copy link
Owner

tugrul commented May 1, 2017

Currently im refactoring codebase of https://github.com/tugrul/libmcrypt-gyp

@misterfresh test case will be better to see to me.

Can you write a test case like one of the file inside of test folder?

It is pretty simple.

Thanks.

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

No branches or pull requests

3 participants