You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
1.0 KiB

namespace com.hitrust.Security.Signature
{
using com.hitrust.Security.Certificates;
using System;
using System.Security.Cryptography;
using System.Text;
internal class Receiver
{
private Certificate iCertificate;
public Receiver(Certificate aCertificate)
{
this.iCertificate = aCertificate;
}
public void DecryptData(byte[] encrypted)
{
ASCIIEncoding myAscii = new ASCIIEncoding();
byte[] fromEncrypt = this.iCertificate.PrivateKey.Decrypt(encrypted, false);
string roundTrip = myAscii.GetString(fromEncrypt);
Console.WriteLine("RoundTrip: {0}", roundTrip);
}
public bool VerifyHash(byte[] signedData, byte[] signature)
{
byte[] hashedData = new SHA1Managed().ComputeHash(signedData);
return this.iCertificate.PublicKey.VerifyHash(hashedData, CryptoConfig.MapNameToOID("SHA1"), signature);
}
}
}