コード例 #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);
            }