function encryption_decrypt
Search API
7.x encryption.module | encryption_decrypt($ciphertext) |
6.x encryption.module | encryption_decrypt($ciphertext) |
This will decrypt an encrypted string.
3 calls to encryption_decrypt()
- content_files_handle_download in modules/
content/ content.module - This actually finds and downloads the file for the user, decrypting if necessary.
- engagements_send_email_or_txt_form_submit in modules/
engagements/ engagements.module - student_files_handle_download in modules/
student_files/ student_files.module - This actually finds and downloads the file for the user, decrypting if necessary.
File
- modules/
encryption/ encryption.module, line 329 - This is the main module file for the encryption module.
Code
function encryption_decrypt($ciphertext) {
$c = base64_decode($ciphertext);
$cipher = encryption_get_cipher_algorithm();
$key = encryption_get_key();
$ivlen = openssl_cipher_iv_length($cipher);
$iv = substr($c, 0, $ivlen);
$hmac = substr($c, $ivlen, $sha2len = 32);
$ciphertext_raw = substr($c, $ivlen + $sha2len);
$original_plaintext = openssl_decrypt($ciphertext_raw, $cipher, $key, OPENSSL_RAW_DATA, $iv);
$calcmac = hash_hmac("sha256", $ciphertext_raw, $key, true);
if ($calcmac && $hmac) {
if (hash_equals($hmac, $calcmac)) {
return base64_decode($original_plaintext);
}
}
return FALSE;
}