RSA encryption but just for strings:
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace RSA
{
class Program
{
static void Main(string[] args)
{
RSACryptoServiceProvider myrsa = new RSACryptoServiceProvider();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
string data = "RsA EnCryPTion is cool!!!";
Byte[] newdata = encoding.GetBytes(data);
Byte[] encrypted = myrsa.Encrypt(newdata, false);
Console.WriteLine("Encrypted Data: ");
for (int i = 0; i < encrypted.Length; i++)
{
Console.Write("{0} ", encrypted[i]);
}
Console.WriteLine();
Console.WriteLine();
Byte[] decrypted = myrsa.Decrypt(encrypted, false);
Console.WriteLine("Decrypted Data: ");
string dData = encoding.GetString(decrypted);
for (int i = 0; i < decrypted.Length; i++)
{
Console.Write("{0}", dData[i]);
}
}
}
}