<tutorialjinni.com/>

Decrypt String Using PHP

Posted Under: PHP, Snippets on Aug 18, 2018
Decrypt String Using PHP
PHP snippet to decrypt AES-256 encrypted string with 32 Bytes key. In order to use decryption php_mcrypt extension need to be installed and activated.
$encryptionKey="EncryptionKeyMustBExactly32Bytes";// 32 bytes Key
$initializationVector="InitializationVectorMustB32Bytes";
$base64EncodedData="krzY/3Gh7xd1U+8zfOGyTweF+QPNTYtOiCz50kcL4SM=";
$encryptedBytes= base64_decode($base64EncodedData);
echo mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $encryptionKey, $encryptedBytes, MCRYPT_MODE_CBC, $initializationVector);
Sample output
My Very special secret message


imgae