public bool VerifyData(byte[] data, byte[] signature) { using (RSACryptoServiceProvider rsaCryptoServiceProvider = RSAContainerFactory.CreateFromPublicKey(_publicKey)) { return(rsaCryptoServiceProvider.VerifyData(data, signature, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1)); } }
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)); } }