diff --git a/aes.module b/aes.module index c4401bd..57f7b96 100644 --- a/aes.module +++ b/aes.module @@ -7,7 +7,7 @@ */ define("AES_PASSWORD_MAX_LENGTH", 128); -define("AES_VERSION_MAGIC_BYTES", "aes-d6lts1\x1a"); +define("AES_MAGIC_BYTES_VERSION1", "aes-d6lts1\x1a"); function aes_menu() { @@ -464,7 +464,7 @@ function aes_encrypt($string, $base64encode = true, $custom_key = null, $custom_ $iv = crypt_random_string($phpsec->getBlockLength() >> 3); $phpsec->setIV($iv); - $encrypted = AES_VERSION_MAGIC_BYTES . $iv . $phpsec->encrypt($string); + $encrypted = AES_MAGIC_BYTES_VERSION1 . $iv . $phpsec->encrypt($string); if($base64encode) { return base64_encode($encrypted); @@ -517,7 +517,7 @@ function aes_decrypt($string, $base64encoded = true, $custom_key = null, $custom } $version = substr($string, 0, 11); - if ($version != AES_VERSION_MAGIC_BYTES) { + if ($version != AES_MAGIC_BYTES_VERSION1) { return aes_decrypt_legacy($string, FALSE, $custom_key, $custom_cipher, $custom_iv, $custom_implementation); } $string = substr($string, 11); @@ -526,12 +526,12 @@ function aes_decrypt($string, $base64encoded = true, $custom_key = null, $custom if (aes_load_phpsec() === TRUE) { $phpsec = new Crypt_AES(); + $phpsec->setKey($key); $iv_length = $phpsec->getBlockLength() >> 3; $iv = substr($string, 0, $iv_length); $string = substr($string, $iv_length); - $phpsec->setKey($key); $phpsec->setIV($iv); $decrypted = $phpsec->decrypt($string);