Dcrypt\Cryptobase::checksum PHP Method

checksum() protected static method

Create a message authentication checksum.
protected static checksum ( string $cyphertext, string $iv, string $key, string $cipher = 'rijndael-128', string $mode = 'cbc', string $algo = 'sha256' ) : string
$cyphertext string Cyphertext that needs a checksum.
$iv string Initialization vector.
$key string HMAC key
$cipher string Cipher string
$mode string Cipher mode string
$algo string Hashing algorithm to use for internal operations
return string
    protected static function checksum($cyphertext, $iv, $key, $cipher = 'rijndael-128', $mode = 'cbc', $algo = 'sha256')
    {
        // Prevent potentially large string concat by hmac-ing the cyphertext
        // by itself...
        $sum = \hash_hmac($algo, $cyphertext, $key, true);
        // ... then hash other elements with previous hmac and return
        return \hash_hmac($algo, $sum . $iv . $mode . $cipher, $key, true);
    }