Skip to content

Instantly share code, notes, and snippets.

Created July 18, 2019 17:37
What would you like to do?
using System;
using System.Security.Cryptography;
class Program
static void Main(string[] args)
var digest = new byte[] {
0x68, 0xB4, 0xF9, 0x26, 0x34, 0x31, 0x25, 0xDD,
0x26, 0x50, 0x13, 0x68, 0xC1, 0x99, 0x26, 0x71,
0x19, 0xA2, 0xDE, 0x81,
var signature = new byte[] {
0x6A, 0xDB, 0x39, 0xE5, 0x63, 0xB3, 0x25, 0xDE,
0x58, 0xCA, 0xC3, 0xF1, 0x36, 0x9C, 0x0B, 0x36,
0xB7, 0xD6, 0x69, 0xF9, 0xBA, 0xA6, 0x68, 0x14,
0x8C, 0x24, 0x52, 0xD3, 0x25, 0xA5, 0xF3, 0xAD,
0xC9, 0x47, 0x44, 0xDE, 0x06, 0xD8, 0x0F, 0x56,
0xCA, 0x2D, 0xFB, 0x0F, 0xE9, 0x99, 0xE2, 0x9D,
0x8A, 0xE8, 0x7F, 0xFB, 0x9A, 0x99, 0x96, 0xF1,
0x2C, 0x4A, 0xE4, 0xC0, 0xAE, 0x4D, 0x29, 0x47,
0x38, 0x96, 0x51, 0x2F, 0x6D, 0x8E, 0xB8, 0x88,
0xBD, 0x1A, 0x0A, 0x70, 0xBC, 0x23, 0x38, 0x67,
0x62, 0x22, 0x01, 0x23, 0x71, 0xE5, 0xBB, 0x95,
0xEA, 0x6B, 0x8D, 0x31, 0x62, 0xBF, 0xF0, 0xC4,
0xB9, 0x46, 0xD6, 0x67, 0xFC, 0x4C, 0xE6, 0x1F,
0xD6, 0x5D, 0xF7, 0xA9, 0xAD, 0x3A, 0xF1, 0xBF,
0xA2, 0xF9, 0x66, 0xDE, 0xB6, 0x8E, 0xEC, 0x8F,
0x81, 0x8D, 0x1E, 0x3A, 0x12, 0x27, 0x6A, 0xFC,
0xAE, 0x92, 0x9F, 0xC3, 0x87, 0xC3, 0xBA, 0x8D,
0x04, 0xB8, 0x8F, 0x0F, 0x61, 0x68, 0x9A, 0x96,
0x2C,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 0xAA, 0xCD,
var e = new byte[] {
0x01, 0x00, 0x01
using (var rsa = new RSACng())
rsa.ImportParameters(new RSAParameters {
Modulus = n,
Exponent = e
var valid = rsa.VerifyHash(digest, signature, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
using (var rsa = new RSACryptoServiceProvider())
rsa.ImportParameters(new RSAParameters {
Modulus = n,
Exponent = e
var valid = rsa.VerifyHash(digest, signature, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment