hmacSHA256 method

String hmacSHA256 (
  1. String secret,
  2. String toSign
)

Implementation

String hmacSHA256(String secret, String toSign) {
  if (secret == null || toSign == null) {
    return "";
  }

  var key = utf8.encode(secret);
  var bytes = utf8.encode(toSign);

  var hmacSha256 = new Hmac(sha256, key);
  var digest = hmacSha256.convert(bytes);

  return digest.toString();
}