我爱Aspx >> Asp.Net >> 从COM组件调用.NET组件编程实战//使得输入密码必须输入英文文本
des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
des.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(),CryptoStreamMode.Write);
//Write the byte array into the crypto stream
//(It will end up in the memory stream)
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
//Get the data back from the memory stream, and into a string
StringBuilder ret = new StringBuilder();
foreach(byte b in ms.ToArray())
{
//Format as hex
ret.AppendFormat("{0:X2}", b);
}
ret.ToString();
return ret.ToString();
}
// 解密的方法
public string Decrypt(string pToDecrypt, string sKey)
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
//Put the input string into the byte array
byte[] inputByteArray = new byte[pToDecrypt.Length / 2];
for(int x = 0; x < pToDecrypt.Length / 2; x++)
{
int i = (Convert.ToInt32(pToDecrypt.Substring(x * 2, 2), 16));
inputByteArray[x] = (byte)i;
}
//建立加密对象的密钥和偏移量,此值重要,不能修改
des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
des.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
Ҷƪл˵?
在C#中使用COM+实现事务控制[04-21]
缓存 ASP.NET 页的某些部分[04-21]
COM,COM+区别[04-21]
使用C#开发COM+组件[04-21]
C# 注册COM+组件步骤[04-21]
c#教程第一讲 开始.net探索之旅[04-21]
.net课件之多线程[04-21]
五子棋.NET源码下载[04-21]
跟我一起学.net资料(二)[04-21]
跟我一起学习.net资料(一)[04-21]
乱画的一大堆哈哈[04-21]
我住的那栋楼下[04-21]
雨中漫步—瞬间的浪漫[04-21]
一辈子的幸福[04-21]
感悟[04-21]
鱼和水,我和你……[04-21]
男朋友与男性好友[04-21]
当我们的心流连在午夜[04-21]
放手的幸福[04-21]
幸福的人不看结局[04-21]