public bool Verify(SignatureSet set, byte[] dataToCheck) { using (var rsa = new RSACryptoServiceProvider()) { rsa.ImportCspBlob(set.publicKey); return(rsa.VerifyData(dataToCheck, hasher, set.signature)); } }
public SignatureSet GetSignature(byte[] data) { using (var rsa = new RSACryptoServiceProvider()) { var sigSet = new SignatureSet { signature = rsa.SignData(data, hasher), publicKey = rsa.ExportCspBlob(false) }; return(sigSet); } }
static void Main(string[] args) { string message = "Our message"; byte[] data = Encoding.UTF8.GetBytes(message); CyberSignature sig = new CyberSignature(); SignatureSet sigSet = sig.GetSignature(data); //data[0] = 222; // var result = sig.Verify(sigSet.publicKey, sigSet.signature, data); var result = sig.Verify(sigSet, data); Console.WriteLine(result); Console.ReadLine(); }