public static bool VerifySignature_2048_Bit_PKCS1_v1_5(byte[] data, byte[] signature, byte[] publicKey) { // Links for information about PKCS #1 version 1.5: // RFC 2313: http://tools.ietf.org/html/rfc2313 // PKCS #1 on Wikipedia: http://en.wikipedia.org/wiki/PKCS_1 var hash = CryptoHash.calculate(data, CryptoHash.Kind.SHA1); // Specify the public key RSAParameters rsaParameters = GetRsaParameters_2048_Bit_PKCS1_v1_5(publicKey); // Use RSACryptoProvider to verify the signature with the public key RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048); rsa.ImportParameters(rsaParameters); RSAPKCS1SignatureDeformatter rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa); rsaDeformatter.SetHashAlgorithm("SHA1"); return(rsaDeformatter.VerifySignature(hash.bytes.internalArray(), signature)); }
string sha256(string data) => CryptoHash.calculate(data, CryptoHash.Kind.SHA256).asString();