public static RSAParameters GetPrivateKeyRSAParameters(string privateKeyString)
 {
     using (var rsa = RsaPEMHelper.PrivateKeyFromPem(privateKeyString))
     {
         return(rsa.ExportParameters(true));
     }
 }
            public static byte[] CreateDigitalSignature(string privateKeyString, byte[] hashOfDataToSign)
            {
                using (var rsa = RsaPEMHelper.PrivateKeyFromPem(privateKeyString))
                {
                    var rsaFormatter = new RSAPKCS1SignatureFormatter(rsa);
                    rsaFormatter.SetHashAlgorithm("SHA256");

                    return(rsaFormatter.CreateSignature(hashOfDataToSign));
                }
            }
            public static byte[] DecryptData(string privateKeyString, byte[] dataToEncrypt)
            {
                byte[] plain;

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

                return(plain);
            }