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);
            }