CryptoStream cryptoStream = new CryptoStream(memoryStream
triprovider
CryptoStreamMode
//定義讀IO流
StreamReader readerStream = new StreamReader(cryptoStream);
//返回解密後的字符串
return(readerStream
}
return(null);
}
}
在應用程序Example_
public class CookieEncrypt
{
public static void SetCookie(HttpCookie cookie)
{ //設置Cookie
HttpContext
}
public static void SetCookie(String key
{ //設置加密後的Cookie
key = HttpContext
valueString = HttpContext
HttpCookie cookie = new HttpCookie(key
SetCookie(cookie);
}
public static void SetCookie(String key
DateTime expires)
{ //設置加密後的Cookie
key = HttpContext
valueString = HttpContext
HttpCookie cookie = new HttpCookie(key
cookie
SetCookie(cookie);
}
public static void SetTripleDESEncryptedCookie(String key
String valueString)
{ //設置使用TripleDES加密後的Cookie
key = EncryptString
valueString = EncryptString
SetCookie(key
}
public static void SetTripleDESEncryptedCookie(String key
String valueString
{ //設置使用TripleDES加密後的Cookie
key = EncryptString
valueString = EncryptString
SetCookie(key
}
[
From:http://tw.wingwit.com/Article/program/net/201311/15122.html