generateSignatureOfHash method

Uint8List generateSignatureOfHash(
  1. RSAPrivateKey privateKey,
  2. Uint8List hash,
  3. HashAlgorithm digestAlgorithm
)

Generate a signature for the message

Implementation

Uint8List generateSignatureOfHash(
  RSAPrivateKey privateKey,
  Uint8List hash,
  HashAlgorithm digestAlgorithm,
) {
  // Encode the hash
  final encodedHash = derEncode(hash, digestAlgorithm);

  // Encrypt the hash with PKCS1 padding
  final param = PrivateKeyParameter<RSAPrivateKey>(privateKey);
  final rsa = PKCS1Encoding(RSAEngine());
  rsa.init(true, param);
  return rsa.process(encodedHash);
}