public static RSAParameters GetPrivateKeyRSAParameters(string privateKeyPath)
 {
     using (var rsa = RSAPEMHelper.PrivateKeyFromPemFile(privateKeyPath))
     {
         return(rsa.ExportParameters(true));
     }
 }
            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));
                }
            }
            public static byte[] DecryptData(string privateKeyPath, byte[] dataToEncrypt)
            {
                byte[] plain;

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

                return(plain);
            }