des加密问题
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Security.Cryptography;
using System.IO;
public partial class Default2 : System.Web.UI.Page
{
private string secretKey1= "aa ";
private string secretKey2= "bb ";
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Text = encrypt1( "aa ");
}
/// <summary>
/// 一次加密
/// </summary>
/// <param name= "pToEncrypt "> 加密内容 </param>
/// <returns> </returns>
private string encrypt1(string pToEncrypt)
{
string EncryptString = " ";
try
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.Default.GetBytes(pToEncrypt);
des.Key = ASCIIEncoding.ASCII.GetBytes(secretKey1);
des.IV = ASCIIEncoding.ASCII.GetBytes(secretKey1);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
StringBuilder ret = new StringBuilder();
foreach (byte b in ms.ToArray())
{
ret.AppendFormat( "{0:X2} ", b);