public static RSAParameters GetPublicKeyRSAParameters(string publicKeyPath)
 {
     using (var rsa = RsaPEMHelper.PublicKeyFromPemFile(publicKeyPath))
     {
         return(rsa.ExportParameters(false));
     }
 }
            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));
                }
            }
            public static byte[] EncryptData(string publicKeyPath, byte[] dataToEncrypt)
            {
                byte[] cipherbytes;

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

                return(cipherbytes);
            }