using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;
namespace Secrituy
{
public class Secure
{
private static byte[] DESKey = new byte[]{11,23,93,102,72,41,18,12};
private static byte[] DESIV = new byte[] { 75, 158, 46, 97, 78, 57, 17, 36 };
public static string Encode(string Encode_String)
{
DESCryptoServiceProvider objDES = new DESCryptoServiceProvider();
MemoryStream objMemoryStream = new MemoryStream();
CryptoStream objCryptoStream = new CryptoStream(objMemoryStream, objDES.CreateEncryptor(DESKey, DESIV), CryptoStreamMode.Write);
StreamWriter objStreamWriter = new StreamWriter(objCryptoStream);
objStreamWriter.Write(Encode_String);
objStreamWriter.Flush();
objCryptoStream.FlushFinalBlock();
objMemoryStream.Flush();
return Convert.ToBase64String(objMemoryStream.GetBuffer(), 0, (int)objMemoryStream.Length);
}
public static string Decode(string Encode_String)
{
DESCryptoServiceProvider objDES = new DESCryptoServiceProvider();
byte[] input = Convert.FromBase64String(Encode_String);
MemoryStream objMemoryStream = new MemoryStream(input);
CryptoStream objCryptoStream = new CryptoStream(objMemoryStream, objDES.CreateDecryptor(DESKey, DESIV), CryptoStreamMode.Read);
StreamReader objStreamReader = new StreamReader(objCryptoStream);
return objStreamReader.ReadToEnd();
}
}
}