一道面试题大家帮忙下!!! js在页面用des加密,密文到后台用c#的des解密程序进行解密,请教高人? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /// <summary>/// DES解密,sKey可为8位或16位,默认请指定为:"8lvbe4kE"/// </summary>/// <param name="pToDecrypt">需要解密的字符串</param>/// <param name="sKey">密钥</param>/// <returns>解密后的字符串</returns>public static string DESDecrypt(string pToDecrypt, string sKey){ DESCryptoServiceProvider des = new DESCryptoServiceProvider(); 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); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); StringBuilder ret = new StringBuilder(); return System.Text.Encoding.Default.GetString(ms.ToArray());} 限制输入框只能输入数字 在线求解决 如何得到barUnitWidth的值???高手请进,救命啊!!!!!! 一个extjs 中两个datefield 值的比较 网站被script挂马 为什么时间和日期的中间那么大空隙呢,在线等! 百度地图api下自定义覆盖物的事件问题 求救!!!!实时更新表单数据,高手请相助!!!!在线急盼 如何使网页浏览时按“shift”键无效! 如何在javascript的函数中,调用另外一个联接 请教一个下拉列表的问题! 定时生成文本文件的功能 javascript 怎么做到WEB讯雷那样的下载目录
/// DES解密,sKey可为8位或16位,默认请指定为:"8lvbe4kE"
/// </summary>
/// <param name="pToDecrypt">需要解密的字符串</param>
/// <param name="sKey">密钥</param>
/// <returns>解密后的字符串</returns>
public static string DESDecrypt(string pToDecrypt, string sKey)
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider(); 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);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock(); StringBuilder ret = new StringBuilder(); return System.Text.Encoding.Default.GetString(ms.ToArray());
}