hmac static method
Calculates an HMAC using a specified hash function, a secret key, and input data.
The hash
parameter should be a function that returns a hash instance, e.g., SHA1, SHA256, etc.
Example:
final key = List<int>.from([0x00, 0x01, 0x02]);
final data = List<int>.from([0x10, 0x11, 0x12, 0x13]);
final hmac = hmac(()=>SHA256(), key, data);
Implementation
static List<int> hmac(HashFunc hash, List<int> key, List<int> data) {
final h = HMAC(hash, key);
h.update(data);
final digest = h.digest();
h.clean();
return digest;
}