Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

function decrypt($data, $password) { $decodedData = base64_decode($data); // E..

Decoded Output download

<?   
function decrypt($data, $password) { 
    $decodedData = base64_decode($data); 
    // Extract the salt, IV, HMAC, and encrypted data 
    $salt = substr($decodedData, 0, 16); 
    $iv = substr($decodedData, 16, openssl_cipher_iv_length('aes-256-cbc')); 
    $hmac = substr($decodedData, 16 + openssl_cipher_iv_length('aes-256-cbc'), 32); 
    $encryptedData = substr($decodedData, 48 + openssl_cipher_iv_length('aes-256-cbc')); 
    $key = hash_pbkdf2('sha256', $password, $salt, 10000, 32, true); 
    $calculatedHmac = hash_hmac('sha256', $encryptedData, $key, true); 
    if (!hash_equals($hmac, $calculatedHmac)) { 
        throw new Exception('Data integrity check failed.'); 
    } 
    return openssl_decrypt($encryptedData, 'aes-256-cbc', $key, 0, $iv); 
} ?>

Did this file decode correctly?

Original Code


function decrypt($data, $password) {
    $decodedData = base64_decode($data);
    // Extract the salt, IV, HMAC, and encrypted data
    $salt = substr($decodedData, 0, 16);
    $iv = substr($decodedData, 16, openssl_cipher_iv_length('aes-256-cbc'));
    $hmac = substr($decodedData, 16 + openssl_cipher_iv_length('aes-256-cbc'), 32);
    $encryptedData = substr($decodedData, 48 + openssl_cipher_iv_length('aes-256-cbc'));
    $key = hash_pbkdf2('sha256', $password, $salt, 10000, 32, true);
    $calculatedHmac = hash_hmac('sha256', $encryptedData, $key, true);
    if (!hash_equals($hmac, $calculatedHmac)) {
        throw new Exception('Data integrity check failed.');
    }
    return openssl_decrypt($encryptedData, 'aes-256-cbc', $key, 0, $iv);
}

Function Calls

None

Variables

None

Stats

MD5 c547c881a439d857c8d44098324260d1
Eval Count 0
Decode Time 49 ms