function _commerce_sagepay_decode_and_decrypt in Drupal Commerce SagePay Integration 7
Decode a returned string from SagePay.
Parameters
string $str_in: The encrypted String.
string $str_encryption_password: The encyption password used to encrypt the string.
Return value
string The unecrypted string.
1 call to _commerce_sagepay_decode_and_decrypt()
- commerce_sagepay_form_redirect_form_validate in includes/
commerce_sagepay_form.inc - Implements hook_redirect_form_validate().
File
- includes/
commerce_sagepay_utils.inc, line 95 - commerce_sagepay_utils.inc Common utilities shared by all Integration methods.
Code
function _commerce_sagepay_decode_and_decrypt($str_in, $str_encryption_password) {
// HEX decoding then AES decryption, CBC blocking with PKCS5 padding.
// Use initialization vector (IV) set from $str_encryption_password.
$str_iv = $str_encryption_password;
// Remove the first char which is @ to flag this is AES encrypted.
$str_in = substr($str_in, 1);
// HEX decoding.
$str_in = pack('H*', $str_in);
// Perform decryption with PHP's MCRYPT module.
return _commerce_sagepay_removePKCS5Padding(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $str_encryption_password, $str_in, MCRYPT_MODE_CBC, $str_iv));
}