verifyHmacSha256 static method
Verifies if the provided value generates the same hash when encrypted with the same key.
Parameters:
- encryptedValue: The Base64 encoded HMAC-SHA256 hash to verify against
- key: The secret key used for encryption (default: 'VNLook')
- valueToCheck: The plaintext value to check against the encrypted hash
Returns: True if the valueToCheck would produce the same hash as encryptedValue when encrypted
Implementation
static bool verifyHmacSha256({
required String encryptedValue,
String key = 'VNLook',
required String valueToCheck
}) {
// Generate hash for the value to check
String generatedHash = encryptHmacSha256(key: key, value: valueToCheck);
// Compare the generated hash with the encrypted value
return generatedHash == encryptedValue;
}