using System;
using System.IO;
using System.Security;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Text;
class Program
{
static void Main(string[] args)
{
StreamReader sr = File.OpenText("myKey.xml");
string myKey = sr.ReadToEnd();
sr.Close();
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(myKey);
FileStream fs = new FileStream("Message.dat", FileMode.Open);
byte[] encrypted = new byte[fs.Length];
fs.Read(encrypted, 0, (int)fs.Length);
byte[] decrypted = rsa.Decrypt(encrypted, false);
fs.Close();
Console.WriteLine(System.Text.ASCIIEncoding.ASCII.GetString(decrypted));
}
}
|