public hashData ( string $data, string $key, boolean $rawHash = false ) : string | ||
$data | string | the data to be protected |
$key | string | the secret key to be used for generating hash. Should be a secure cryptographic key. |
$rawHash | boolean | whether the generated hash value is in raw binary format. If false, lowercase hex digits will be generated. |
return | string | the data prefixed with the keyed hash |
public function hashData($data, $key, $rawHash = false)
{
$hash = hash_hmac($this->macHash, $data, $key, $rawHash);
if (!$hash) {
throw new InvalidConfigException('Failed to generate HMAC with hash algorithm: ' . $this->macHash);
}
return $hash . $data;
}