Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public static byte[] Encrypt(byte[] plainBytes, X509Certificate2 cert)
  2. {
  3. RSACryptoServiceProvider publicKey = (RSACryptoServiceProvider)cert.PublicKey.Key;
  4. byte[] encryptedBytes = publicKey.Encrypt(plainBytes, false);
  5. return encryptedBytes;
  6. }
  7.  
  8. public static byte[] Decrypt(byte[] encryptedBytes, X509Certificate2 cert)
  9. {
  10. RSACryptoServiceProvider privateKey = (RSACryptoServiceProvider)cert.PrivateKey;
  11. byte[] decryptedBytes = privateKey.Decrypt(encryptedBytes, false);
  12. return decryptedBytes;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement