-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
Description
We are re-writing our php app to node js app and trying to decrypt the password which is encrypted using php encrypt by twofish.
$this->load->library('encrypt');
$this->encrypt->set_cipher(MCRYPT_TWOFISH);
$encodedPass = $this->encrypt->encode($_POST['password']);
Mode defaulted to cbc.
Here is my decrypt code using in node js:
var ivAndCiphertext = new Buffer(ENCRYPTED_PASSWORD, 'base64');
var twofishCbc = new MCrypt('twofish', 'cbc');
var ivSize = twofishCbc.getIvSize();
var iv = new Buffer(ivSize);
var cipherText = new Buffer(ivAndCiphertext.length - ivSize);
ivAndCiphertext.copy(iv, 0, 0, ivSize);
ivAndCiphertext.copy(cipherText, 0, ivSize);
twofishCbc.open('somekey', iv);
console.log(twofishCbc.decrypt(cipherText).toString());
I am stuck here. Could you please help me how to decrypt using mcrypt library.