Hi Tasos,
when I use your example in c# and php I receive an error massage in php:
error:0606508A:digital envelope routines:EVP_DecryptFinal_ex:data not multiple of block length
c# code is:
string data = "my data";
string passphrase = "my super strong password";
AesEncryption aes = new AesEncryption("cfb");
byte[] enc = aes.Encrypt(data, passphrase);
Debug.WriteLine(Encoding.ASCII.GetString(enc));
//1cFI7AVmg/M7Z84ALEKVC2ZEOfof5qHP5CrIqYF3+1j7OOzDcM8BPjh1IZeVj4wyKDryRKwpIxmfzKI7xXixC2ZYmnl+JP4=
php code is:
$data = "1cFI7AVmg/M7Z84ALEKVC2ZEOfof5qHP5CrIqYF3+1j7OOzDcM8BPjh1IZeVj4wyKDryRKwpIxmfzKI7xXixC2ZYmnl+JP4=";
$password = "my super strong password";
$aes = new AesEncryption();
$dec = $aes->decrypt($data, $password);
echo $dec;
//error:0606508A:digital envelope routines:EVP_DecryptFinal_ex:data not multiple of block length
Sorry for the late reply, I just noticed this issue. In your code above you're using different modes - CFB in C# and CBC in PHP (CBC is the default). You should be able to get correct results if you use the same mode
Hi Tasos, when I use your example in c# and php I receive an error massage in php: error:0606508A:digital envelope routines:EVP_DecryptFinal_ex:data not multiple of block length
c# code is: string data = "my data"; string passphrase = "my super strong password"; AesEncryption aes = new AesEncryption("cfb"); byte[] enc = aes.Encrypt(data, passphrase); Debug.WriteLine(Encoding.ASCII.GetString(enc)); //1cFI7AVmg/M7Z84ALEKVC2ZEOfof5qHP5CrIqYF3+1j7OOzDcM8BPjh1IZeVj4wyKDryRKwpIxmfzKI7xXixC2ZYmnl+JP4=
php code is: $data = "1cFI7AVmg/M7Z84ALEKVC2ZEOfof5qHP5CrIqYF3+1j7OOzDcM8BPjh1IZeVj4wyKDryRKwpIxmfzKI7xXixC2ZYmnl+JP4="; $password = "my super strong password"; $aes = new AesEncryption(); $dec = $aes->decrypt($data, $password); echo $dec; //error:0606508A:digital envelope routines:EVP_DecryptFinal_ex:data not multiple of block length
Do you have any idea? Regards Horst