温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:虫虫留言本Ver1.0源码
当前文件:
ChongChongGuestBook/App_Code/Encryption.cs[1K,2009-6-12 11:35:43],打开代码结构图
ChongChongGuestBook/App_Code/Encryption.cs[1K,2009-6-12 11:35:43],打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Web; 5
using System.Web.Security; 6
using System.Web.UI; 7
using System.Web.UI.WebControls; 8
using System.Web.UI.WebControls.WebParts; 9
using System.Web.UI.HtmlControls; 10
11
/// <summary> 12
/// Encryption 的摘要说明 13
/// </summary> 14
public class Encryption 15
{ 16
public Encryption() 17
{ 18
// 19
// TODO: 在此处添加构造函数逻辑 20
// 21
} 22
23
/// <summary> 24
/// encrypting string《加密》 25
/// </summary> 26
/// <returns></returns> 27
public static string Encrypt(string Password) 28
{ 29
string str = ""; 30
FormsAuthenticationTicket ticket = new System.Web.Security.FormsAuthenticationTicket(Password, true, 2); 31
str = FormsAuthentication.Encrypt(ticket).ToString(); 32
return str; 33
} 34
35
/// <summary> 36
/// encrypting string《SHA1 or MD5加密》 37
/// </summary> 38
/// <param name="Password">encrypting string</param> 39
/// <param name="Format">format,0 is SHA1,1 is MD5</param> 40
/// <returns></returns> 41
public static string pwencrypt(string Password, int Format) 42
{ 43
string str = ""; 44
switch (Format) 45
{ 46
case 0: 47
str = FormsAuthentication.HashPasswordForStoringInConfigFile(Password, "SHA1"); 48
break; 49
case 1: 50
str = FormsAuthentication.HashPasswordForStoringInConfigFile(Password, "MD5"); 51
break; 52
} 53
return str; 54
} 55
56
/// <summary> 57
/// decrypt string《解密》 58
/// </summary> 59
/// <param name="Passowrd">encrypted string</param> 60
/// <returns></returns> 61
public static string Decrypt(string Passowrd) 62
{ 63
string str = ""; 64
str = FormsAuthentication.Decrypt(Passowrd).Name.ToString(); 65
return str; 66
} 67
68
69
70
} 71









