Пример #1
0
 public static RSAParameters GetPrivateKeyRSAParameters(string privateKeyPath)
 {
     using (var rsa = RsaPEMHelper.PrivateKeyFromPemFile(privateKeyPath))
     {
         return(rsa.ExportParameters(true));
     }
 }
Пример #2
0
            public static byte[] CreateDigitalSignature(string privateKeyPath, byte[] hashOfDataToSign)
            {
                using (var rsa = RsaPEMHelper.PrivateKeyFromPemFile(privateKeyPath))
                {
                    var rsaFormatter = new RSAPKCS1SignatureFormatter(rsa);
                    rsaFormatter.SetHashAlgorithm("SHA256");

                    return(rsaFormatter.CreateSignature(hashOfDataToSign));
                }
            }
Пример #3
0
            public static byte[] DecryptData(string privateKeyPath, byte[] dataToEncrypt)
            {
                byte[] plain;

                using (var rsa = RsaPEMHelper.PrivateKeyFromPemFile(privateKeyPath))
                {
                    plain = rsa.Decrypt(dataToEncrypt, false);
                }

                return(plain);
            }