Example #1
0
 public static RSAParameters GetPublicKeyRSAParameters(string publicKeyString)
 {
     using (var rsa = RsaPEMHelper.PublicKeyFromPem(publicKeyString))
     {
         return(rsa.ExportParameters(false));
     }
 }
Example #2
0
            public static bool VerifySignature(string publicKeyString, byte[] hashOfDataToSign, byte[] signature)
            {
                using (var rsa = RsaPEMHelper.PublicKeyFromPem(publicKeyString))
                {
                    var rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
                    rsaDeformatter.SetHashAlgorithm("SHA256");

                    return(rsaDeformatter.VerifySignature(hashOfDataToSign, signature));
                }
            }
Example #3
0
            public static byte[] EncryptData(string publicKeyString, byte[] dataToEncrypt)
            {
                byte[] cipherbytes;

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

                return(cipherbytes);
            }