using System;
using System.Security;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Text;
class Program
{
static void Main(string[] args)
{
string fileMessage = "this is another test";
byte[] fileMsgArray = System.Text.ASCIIEncoding.ASCII.GetBytes(fileMessage);
byte[] entropy = { 0, 1, 3, 5, 7, 9 };
byte[] protectedMessage = ProtectedData.Protect(fileMsgArray, entropy, DataProtectionScope.CurrentUser);
Console.WriteLine("Protected byte array:");
Console.WriteLine(System.Text.ASCIIEncoding.ASCII.GetString(protectedMessage));
byte[] clearMessage = ProtectedData.Unprotect(protectedMessage, entropy, DataProtectionScope.CurrentUser);
Console.WriteLine("Unprotected/Decrypted Data:");
Console.WriteLine(ASCIIEncoding.ASCII.GetString(clearMessage));
}
}
|