{ //定義DES的Provider
DESCryptoServiceProvider desprovider =
new DESCryptoServiceProvider();
//轉換解密的字符串為二進制
byte[] buffer = Convert
//定義內存流
MemoryStream memoryStream = new MemoryStream();
//定義加密流
CryptoStream cryptoStream = new CryptoStream(memoryStream
desprovider
CryptoStreamMode
//定義讀IO流
StreamReader readerStream = new StreamReader(cryptoStream);
//返回解密後的字符串
return(readerStream
}
return(null);
}
public static String EncryptTripleDES(String valueString)
{
if(valueString !=
{ //定義TripleDES的Provider
TripleDESCryptoServiceProvider triprovider =
new TripleDESCryptoServiceProvider();
//定義內存流
MemoryStream memoryStream = new MemoryStream();
//定義加密流
CryptoStream cryptoStream = new CryptoStream(memoryStream
triprovider
CryptoStreamMode
//定義寫IO流
StreamWriter writerStream = new StreamWriter(cryptoStream);
//寫入加密後的字符流
writerStream
writerStream
cryptoStream
memoryStream
//返回加密後的字符串
return(Convert
(int)memoryStream
}
return(null);
}
public static String DecryptTripleDES(String valueString)
{
if(valueString !=
{ //定義TripleDES的Provider
TripleDESCryptoServiceProvider triprovider =
new TripleDESCryptoServiceProvider();
//轉換解密的字符串為二進制
byte[] buffer = Convert
//定義內存流
MemoryStream memoryStream = new MemoryStream();
//定義加密流
[
From:http://tw.wingwit.com/Article/program/net/201311/15125.html