Asymmetric cryptography : RSA « Security « C# / CSharp Tutorial

C# / CSharp Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statement
5. String
6. struct
7. Class
8. Operator Overload
9. delegate
10. Attribute
11. Data Structure
12. Assembly
13. Date Time
14. Development
15. File Directory Stream
16. Preprocessing Directives
17. Regular Expression
18. Generic
19. Reflection
20. Thread
21. I18N Internationalization
22. GUI Windows Forms
23. 2D
24. Design Patterns
25. Windows
26. XML
27. ADO.Net
28. Network
29. Directory Services
30. Security
31. unsafe
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / CSharp Tutorial » Security » RSA 
30. 10. 1. Asymmetric cryptography
using System;
using System.IO;
using System.Security.Cryptography;

class MainClass
{
  public static void Main() 
  {
    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

    Byte[] testData = {12345678};

    Byte[] encryptedData = rsa.Encrypt(testData, false);
    Console.WriteLine("Encrypted data:");
    for(int i=0; i<encryptedData.GetLength(0); i++)
    {
      Console.Write("{0} ", encryptedData[i]);
    }

    Byte[] decryptedData = rsa.Decrypt(encryptedData, false);
    Console.WriteLine("Decrypted Data:");
    for(int i=0; i<decryptedData.GetLength(0); i++)
    {
      Console.Write("{0} ", decryptedData[i]);
    }
  }

}
Encrypted data:
105 216 155 138 34 149 122 27 220 172 6 69 23 21 224 142 30 166 81 141 15 234 144 235 122 187 99 245
 222 252 154 234 211 79 251 80 253 221 94 91 222 86 225 17 0 96 161 179 155 251 123 140 38 6 161 78
111 193 19 222 251 74 172 104 100 61 39 106 113 67 69 45 237 47 194 189 62 168 98 230 196 149 249 11
3 29 19 66 10 84 73 110 142 142 255 120 138 200 207 79 190 151 164 53 4 198 254 78 203 86 102 233 10
7 216 13 41 166 125 155 58 48 214 27 116 93 211 176 191 183 Decrypted Data:
1 2 3 4 5 6 7 8
30. 10. RSA
30. 10. 1. Asymmetric cryptography
w__w___w_._jav__a__2s___.c_o__m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.