I'm trying to learn how to perform a simple encrypt/decrypt between a Windows 64 machine (my PC) and PHP running on a Linux web server using openSSL.
On my Windows machine, I've installed OpenSSL v1.0.2k for Win64 and I'm using the following command to create an encrypted string using a simple password and a simple key located in secretkey.txt.
enc -aes-256-cbc -A -base64 -nopad -nosalt -pass pass:hello -in secretkey.txt
When I run the command above, I get the following string:
3WE7cuBFhuLCn3/ZBnUrBn68nn3tVn0NKKz63B3uvoc=
Using the string above, I would expect PHP on my Linux web server to be able to decrypt it like this:
$encrypted = '3WE7cuBFhuLCn3/ZBnUrBn68nn3tVn0NKKz63B3uvoc=';
$enc = 'aes-256-cbc';
$password = 'hello';
$key = openssl_decrypt($encrypted, $enc, $password, OPENSSL_ZERO_PADDING);
echo $key .' should equal this-1234-is-4567-my-8910-secret';
But, instead I get this:
9(j���T]��$�W�Ma��S��zz�>.( should equal this-1234-is-4567-my-8910-secret
I've reviewed the following sites and tried multiple versions, but I can't get it to decrypt properly: