Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static byte[] Encrypt(byte[] plainBytes, X509Certificate2 cert)
- {
- RSACryptoServiceProvider publicKey = (RSACryptoServiceProvider)cert.PublicKey.Key;
- byte[] encryptedBytes = publicKey.Encrypt(plainBytes, false);
- return encryptedBytes;
- }
- public static byte[] Decrypt(byte[] encryptedBytes, X509Certificate2 cert)
- {
- RSACryptoServiceProvider privateKey = (RSACryptoServiceProvider)cert.PrivateKey;
- byte[] decryptedBytes = privateKey.Decrypt(encryptedBytes, false);
- return decryptedBytes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement