예제 #1
0
 public static RSAParameters GetPublicKeyRSAParameters(string publicKeyPath)
 {
     using (var rsa = RsaPEMHelper.PublicKeyFromPemFile(publicKeyPath))
     {
         return(rsa.ExportParameters(false));
     }
 }
예제 #2
0
            public static bool VerifySignature(string publicKeyPath, byte[] hashOfDataToSign, byte[] signature)
            {
                using (var rsa = RsaPEMHelper.PublicKeyFromPemFile(publicKeyPath))
                {
                    var rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
                    rsaDeformatter.SetHashAlgorithm("SHA256");

                    return(rsaDeformatter.VerifySignature(hashOfDataToSign, signature));
                }
            }
예제 #3
0
            public static byte[] EncryptData(string publicKeyPath, byte[] dataToEncrypt)
            {
                byte[] cipherbytes;

                using (var rsa = RsaPEMHelper.PublicKeyFromPemFile(publicKeyPath))
                {
                    cipherbytes = rsa.Encrypt(dataToEncrypt, false);
                }

                return(cipherbytes);
            }