温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:内文广告管理系统V1.1版源码
当前文件:
TextAd/App_Code/Tools.cs,打开代码结构图
TextAd/App_Code/Tools.cs,打开代码结构图1using System; 2
using System.Text; 3
using System.IO; 4
using System.Web.UI; 5
using System.Web.UI.WebControls; 6
using System.Data.OleDb; 7
using System.Data; 8
using System.Web; 9
using System.Collections.Generic; 10
using System.Security.Cryptography; 11
12
//该源码下载自www.a s p x 1.com(51aspx.com) 13
//工具类 14
public class Tools 15
{ 16
public Tools() 17
{ 18
} 19
// 得到加密字符串 20
//strText:要加密字符串;strEncrKey:密钥;返回:加密后字符串 21
public static string Encrypt(string strText, string strEncrKey)//加密函数 22
{ 23
byte[] byKey = null;//初始化密钥 24
byte[] IV = { 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x11, 0x12 }; 25
try 26
{ 27
byKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey);//获取密钥 28
DESCryptoServiceProvider des = new DESCryptoServiceProvider(); 29
byte[] inputByteArray = Encoding.UTF8.GetBytes(strText);//输入的字符串转化成字节型 30
MemoryStream ms = new MemoryStream(); 31
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write); 32
cs.Write(inputByteArray, 0, inputByteArray.Length);//输出加密流 33
cs.FlushFinalBlock(); 34
return Convert.ToBase64String(ms.ToArray()); 35
} 36
catch (System.Exception error) 37
{ 38
return "error:" + error.Message + "\r"; 39
} 40
} 41
} 42





}
}