using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Diagnostics;
using System.Security.Cryptography;
namespace MMT
{
public class Encryptdata
{
//ENCRYPT THE PASSWORD KEY(OPEN,EDIT)
public static string Encrypt(string originalString)
{
if (String.IsNullOrEmpty(originalString))
{
originalString = "NO";
//throw new ArgumentNullException("The string which needs to be encrypted can not be null.");
}
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoProvider.CreateEncryptor(bytes, bytes), CryptoStreamMode.Write);
StreamWriter writer = new StreamWriter(cryptoStream);
writer.Write(originalString);
writer.Flush();
cryptoStream.FlushFinalBlock();
writer.Flush();
return Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
}
static byte[] bytes = ASCIIEncoding.ASCII.GetBytes("ZeroCool");
public static string Decrypt(string cryptedString)
{
if (String.IsNullOrEmpty(cryptedString))
{
cryptedString = "NO";
cryptedString = Encrypt(cryptedString);
//throw new ArgumentNullException("The string which needs to be decrypted can not be null.");
}
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(cryptedString));
CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoProvider.CreateDecryptor(bytes, bytes), CryptoStreamMode.Read);
StreamReader reader = new StreamReader(cryptoStream);
return reader.ReadToEnd();
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Diagnostics;
using System.Security.Cryptography;
namespace MMT
{
public class Encryptdata
{
//ENCRYPT THE PASSWORD KEY(OPEN,EDIT)
public static string Encrypt(string originalString)
{
if (String.IsNullOrEmpty(originalString))
{
originalString = "NO";
//throw new ArgumentNullException("The string which needs to be encrypted can not be null.");
}
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoProvider.CreateEncryptor(bytes, bytes), CryptoStreamMode.Write);
StreamWriter writer = new StreamWriter(cryptoStream);
writer.Write(originalString);
writer.Flush();
cryptoStream.FlushFinalBlock();
writer.Flush();
return Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
}
static byte[] bytes = ASCIIEncoding.ASCII.GetBytes("ZeroCool");
public static string Decrypt(string cryptedString)
{
if (String.IsNullOrEmpty(cryptedString))
{
cryptedString = "NO";
cryptedString = Encrypt(cryptedString);
//throw new ArgumentNullException("The string which needs to be decrypted can not be null.");
}
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(cryptedString));
CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoProvider.CreateDecryptor(bytes, bytes), CryptoStreamMode.Read);
StreamReader reader = new StreamReader(cryptoStream);
return reader.ReadToEnd();
}
}
}