using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using System.IO;
public partial class ResourceDownInfo : System.Web.UI.Page
{
static string ResourceId;
public static DataTable ResourceInfo;
protected void Page_Load(object sender, EventArgs e)
{
try
{
ResourceId = Request.QueryString["File"];
bindInfo();
}
catch
{
Response.Redirect("ResourceDownList.aspx");
}
}
private void bindInfo()
{
string GetResourceInfo = "select * from ResourceInfo where ResourceId = " + ResourceId;
ResourceInfo = new common().ExcuteReader(GetResourceInfo).Tables[0];
}
///
/// 对字符串进行加密
///
/// 要加密的字符串
/// 8位工作密钥
/// 加密后的字符串
public static string Encode(string str, string key)
{
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
provider.Key = Encoding.ASCII.GetBytes(key.Substring(0, 8));
provider.IV = Encoding.ASCII.GetBytes(key.Substring(0, 8));
byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(str);
MemoryStream stream = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream, provider.CreateEncryptor(), CryptoStreamMode.Write);
stream2.Write(bytes, 0, bytes.Length);
stream2.FlushFinalBlock();
StringBuilder builder = new StringBuilder();
foreach (byte num in stream.ToArray())
{
builder.AppendFormat("{0:X2}", num);
}
stream.Close();
return builder.ToString();
}
}