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.
 
 

28 lines
775 B

namespace com.hitrust.Security.Signature
{
using com.hitrust.Security.Certificates;
using System;
using System.Security.Cryptography;
internal class Sender
{
private Certificate iCertificate;
public Sender(Certificate aCertificate)
{
this.iCertificate = aCertificate;
}
public byte[] EncryptData(byte[] toEncrypt)
{
return this.iCertificate.PublicKey.Encrypt(toEncrypt, false);
}
public byte[] HashAndSign(byte[] encrypted)
{
byte[] hashedData = new SHA1Managed().ComputeHash(encrypted);
return this.iCertificate.PrivateKey.SignHash(hashedData, CryptoConfig.MapNameToOID("SHA1"));
}
}
}