thorpedosg

8RhAGvNy

Aug 6th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. Encrypting data using RSACryptoServiceProvider has what seems to me as a bizarre feature
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Security.Cryptography;
  7. using System.IO;
  8.  
  9. namespace EncryptionTest
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. UnicodeEncoding ByteConverter = new UnicodeEncoding();
  16.  
  17. byte[] dataToEncrypt = ByteConverter.GetBytes("Test data");
  18.  
  19. string enc = Encrypt(dataToEncrypt);
  20. }
  21.  
  22. static string Encrypt(byte[] data)
  23. {
  24. UnicodeEncoding ByteConverter = new UnicodeEncoding();
  25. RSACryptoServiceProvider encrypt = new RSACryptoServiceProvider();
  26.  
  27. byte[] encryptedData = encrypt.Encrypt(data, false); //Repeat this line
  28.  
  29. return ByteConverter.GetString(encryptedData);
  30. }
  31.  
  32. }
  33. }
Add Comment
Please, Sign In to add comment