note 89419 added to function.mcrypt-decrypt

From: Date: Fri, 06 Mar 2009 23:45:05 +0000
Subject: note 89419 added to function.mcrypt-decrypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-151575@lists.php.net to get a copy of this message
I am trying to use PHP decode to decrypt a message that was encrypted using the BSD implementation of Rijndael in CBC mode with a zero filled IV, with the data encoded in base64. I implemented the program using the BSD source for the crypt/rijndael library. The key was in hex, so I converted it to binary with a call to pack('H*', $key) in the call to mcrypt_encrypt. the php code is: $decoded = base64_decode($cryptext); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); // split the input into the iv and the message. $iv = substr($decoded,0,$iv_size); $string = substr($decoded,$iv_size); // decrypt it. $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, pack('H*', $key), $string, MCRYPT_MODE_CBC, $iv); $plaintext = utf8_decode($decrypted); When I decrypt a message/key produced by PHP it works fine. When I decrypt a message/key produced by the C program, I get garbage back. I also tried doing different things with the iv block, as I noticed that PHP needs 32 characters, and the C methods need 16. Thanks in advance... ---- Server IP: 209.41.74.194 Probable Submitter: 65.189.21.25 ---- Manual Page -- http://www.php.net/manual/en/function.mcrypt-decrypt.php Edit -- https://master.php.net/note/edit/89419 Del: integrated -- https://master.php.net/note/delete/89419/integrated Del: useless -- https://master.php.net/note/delete/89419/useless Del: bad code -- https://master.php.net/note/delete/89419/bad+code Del: spam -- https://master.php.net/note/delete/89419/spam Del: non-english -- https://master.php.net/note/delete/89419/non-english Del: in docs -- https://master.php.net/note/delete/89419/in+docs Del: other reasons-- https://master.php.net/note/delete/89419 Reject -- https://master.php.net/note/reject/89419 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151575) next »