温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:风讯dotNETCMSv1.0免安装版源码
当前文件:
FooSunCMS/Foosun.CMS/FsSecurity.cs[4K,2009-6-12 11:42:42],打开代码结构图
FooSunCMS/Foosun.CMS/FsSecurity.cs[4K,2009-6-12 11:42:42],打开代码结构图1//=========================================================== 2
//== (c)2007 Foosun Inc. by dotNETCMS 1.0 == 3
//== Forum:bbs.foosun.net == 4
//== website:www.foosun.net == 5
//== Address:NO.109 HuiMin ST.,Chengdu ,China == 6
//== TEL:86-28-85098980/66026180 == 7
//== qq:655071,MSN:ikoolls@gmail.com == 8
//== Code By Y.xiaoBin == 9
//=========================================================== 10
using System; 11
using System.IO; 12
using System.Web; 13
using System.Data; 14
using System.Data.SqlClient; 15
using System.Configuration; 16
using System.Security.Cryptography; 17
using System.Text; 18
19
namespace Foosun.CMS 20
{ 21
/// <summary> 22
/// Foosun 的摘要说明 23
/// </summary> 24
public class FSSecurity 25
{ 26
public FSSecurity() 27
{ 28
// 29
// TODO: 在此处添加构造函数逻辑 30
// 31
} 32
33
/// <summary> 34
/// DES加密 35
/// </summary> 36
/// <param name="dit">1为加密码,其它数字为解密</param> 37
/// <param name="strData">待加密/解密字符串</param> 38
/// <param name="key">32位Key值</param> 39
/// <returns>加密后的字符串</returns> 40
public static string FDESEncrypt(string strData, int dit) 41
{ 42
byte[] DESKey = new byte[] { 0x82, 0xBC, 0xA1, 0x6A, 0xF5, 0x87, 0x3B, 0xE6, 0x59, 0x6A, 0x32, 0x64, 0x7F, 0x3A, 0x2A, 0xBB, 0x2B, 0x68, 0xE2, 0x5F, 0x06, 0xFB, 0xB8, 0x2D, 0x67, 0xB3, 0x55, 0x19, 0x4E, 0xB8, 0xBF, 0xDD }; 43
if (dit == 1) 44
{ 45
return DESEncrypt(strData, DESKey); 46
} 47
else 48
{ 49
return DESDecrypt(strData, DESKey); 50
} 51
} 52
53
54
/// <param name="strData">待加密字符串</param> 55
/// <param name="key">32位Key值</param> 56
public static string DESEncrypt(string strData, byte[] key) 57
{ 58
SymmetricAlgorithm fs = Rijndael.Create(); 59
fs.Key = key; 60
fs.Mode = CipherMode.ECB; 61
fs.Padding = PaddingMode.Zeros; 62
MemoryStream ms = new MemoryStream(); 63
CryptoStream cs = new CryptoStream(ms, fs.CreateEncryptor(), CryptoStreamMode.Write); 64
byte[] byt = Encoding.Unicode.GetBytes(strData); 65
cs.Write(byt, 0, byt.Length); 66
cs.FlushFinalBlock(); 67
cs.Close(); 68
return Convert.ToBase64String(ms.ToArray()); 69
} 70
71
//----------------DES解密方式------------------------------- 72
/// <param name="key">32位Key值</param> 73
/// <returns>解密后的字符串</returns> 74
public static string DESDecrypt(string strData, byte[] key) 75
{ 76
SymmetricAlgorithm fs = Rijndael.Create(); 77
fs.Key = key; 78
fs.Mode = CipherMode.ECB; 79
fs.Padding = PaddingMode.Zeros; 80
ICryptoTransform ct = fs.CreateDecryptor(); 81
byte[] byt = Convert.FromBase64String(strData); 82
MemoryStream ms = new MemoryStream(byt); 83
CryptoStream cs = new CryptoStream(ms, ct, CryptoStreamMode.Read); 84
StreamReader sr = new StreamReader(cs, Encoding.Unicode); 85
return sr.ReadToEnd(); 86
} 87
88
/// <summary> 89
/// 序列号控制 90
/// </summary> 91
/// <param name="snStr"></param> 92
/// <param name="userWebsite"></param> 93
public static void userControls(string snStr, string userWebsite) 94
{ 95
96
97
} 98
99
/// <summary> 100
/// 版权所有 101
/// </summary> 102
/// <param name="VersionNUm"></param> 103
/// <returns></returns> 104
public static string CopyRightInfo(int VersionNUm) 105
{ 106
string CrI = "<span style=\"line-height:20px;font-size:11.5px;font-family:Arial;\">" + Foosun.Config.UIConfig.copyright + "</span>"; 107
if (VersionNUm != 999) 108
{ 109
CrI += "<br />" + gCopyRightInfo(); 110
} 111
return CrI; 112
} 113
114
public static string gCopyRightInfo() 115
{ 116
string isTryversion = Foosun.Config.verConfig.isTryversion; 117
string helpcenterStr =Foosun.Config.verConfig.helpcenterStr; 118
string ForumStr = Foosun.Config.verConfig.ForumStr; 119
string CrI = isTryversion + ", " + helpcenterStr + ", " + ForumStr + ""; 120
return CrI; 121
} 122
} 123
} 124









}