sign method

  1. @override
Uint8List sign(
  1. JWTKey key,
  2. Uint8List body
)
override

Create a signature of the body with key

return the signature as bytes

Implementation

@override
Uint8List sign(JWTKey key, Uint8List body) {
  assert(key is SecretKey, 'key must be a SecretKey');
  final secretKey = key as SecretKey;

  final hmac = Hmac(
    _getHash(name),
    secretKey.isBase64Encoded
        ? base64Decode(secretKey.key)
        : utf8.encode(secretKey.key),
  );

  return Uint8List.fromList(hmac.convert(body).bytes);
}