Skip to content

decrypt text encrypted through php encrypt #35

Description

@pmaganti

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions