Exemplo n.º 1
0
 public bool VerifyData(byte[] data, byte[] signature)
 {
     using (RSACryptoServiceProvider rsaCryptoServiceProvider = RSAContainerFactory.CreateFromPublicKey(_publicKey))
     {
         return(rsaCryptoServiceProvider.VerifyData(data, signature, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1));
     }
 }
Exemplo n.º 2
0
        public byte[] EncryptData(byte[] data)
        {
            if (_publicKey == null)
            {
                using (RSACryptoServiceProvider rsaCryptoServiceProvider = RSAContainerFactory.Create(_containerName, _username))
                {
                    return(rsaCryptoServiceProvider.Encrypt(data, RSAEncryptionPadding.Pkcs1));
                }
            }

            using (RSACryptoServiceProvider rsaCryptoServiceProvider = RSAContainerFactory.CreateFromPublicKey(_publicKey))
            {
                return(rsaCryptoServiceProvider.Encrypt(data, RSAEncryptionPadding.Pkcs1));
            }
        }