日期:2014-05-17 浏览次数:20521 次
/// <summary>
/// 类型:方法
/// 方法名称:加密字符串
/// 方法说明:根据传入的字符串和密匙返回加密后的字串
/// </summary>
/// <param name="strText">加密前的原文</param>
/// <param name="strKey">密匙</param>
/// <returns>加密后的字串</returns>
public static string Encrypt(string strText, string strKey)
{
strKey += "etk579@#$am";
Byte[] byKey = { };
Byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(strKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
Byte[] inputByteArray = System.Text.Encoding.UTF8.GetBytes(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);
&n