node-mcrypt
node-mcrypt copied to clipboard
decrypt text encrypted through php encrypt
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.
I dont know that php framework how could handle iv. Stackoverflow can be helpful than bug report. Thanks
I wasn't able to mark it as question. Can you mark this as question and keep it opened so that someone can help if they did this earlier.
PHP framework is CodeIgniter mcrypt library. I too posted in stackoverflow.