0

I have a problem to decrypt with openssl.exe a string encrypted with "openssl_encrypt()".

I crypt my string with PHP like this:

$string = 'This is a test.';
$pass = '123ThisIsAPass987';
$method = 'bf-cbc';
$options = OPENSSL_RAW_DATA;
$iv = 23693999;

echo "iv (hex): ".unpack("H*", $iv)[1];
echo "<br>pass (hex): ".unpack("H*", $pass)[1];
echo "<br>";

file_put_contents('./file.encrypted', openssl_encrypt($string, $method, $pass, $options, $iv));

And when I decrypt with this command, I don't get the correct result:

openssl.exe enc -bf-cbc -d -in file.encrypted -out file.decrypted -nosalt -nopad -K 3132335468697349734150617373393837 -iv 3233363933393939

Thx for your help.

Tovich
  • 535
  • 1
  • 5
  • 15
  • Possible duplicate: [PHP Encrypt Data, Bash Decrypt it](http://stackoverflow.com/q/7477302). Related: [AES | Encrypt with OpenSSL, decrypt with mcrypt](http://stackoverflow.com/q/18312657) and [openssl not generating the same key and iv from command line as it does within c++ code](http://stackoverflow.com/q/15009678). Pay particular attention to OpnSSL's [EVP_BytesToKey](https://wiki.openssl.org/index.php/Manual:EVP_BytesToKey(3)) – jww Aug 17 '16 at 19:58
  • Possible duplicate of [PHP Encrypt Data, Bash Decrypt it](http://stackoverflow.com/questions/7477302/php-encrypt-data-bash-decrypt-it) – miken32 Mar 24 '17 at 23:38

0 Answers0