密码加密,求如何解密

peng_840228 2010-01-28 09:53:19
把下列代码,复制到记事本另存为HTML,求 DecryptionPassword()的解密方法。先谢过了

<html>
<head>
<title>
Title
</title>
</head>
<script language="JavaScript">
function EncryptPassword(){
var password = document.getElementById("yy").value;
var baseByte = 65; //'A'
var key = "ol94hQz2h5Nb4zuWj";
var pw = (StringToFourBit(ApplyXORKey(password, key), baseByte));
document.ff.elements["tt"].value = pw;
//return password;
}
function StringToFourBit(value, baseByte){
if (!value)
return "";
var newValue = "";
var loop1 = 0;
for (loop1=0;loop1<value.length;loop1++){
var b = (value.charCodeAt(loop1));
var hiBits = (((b & 0xF0)>> 4) + baseByte);
var lowBits = ((b & 0x0F) + baseByte);
newValue += String.fromCharCode(hiBits);
newValue += String.fromCharCode(lowBits);
}

return newValue;
}
function ApplyXORKey(value, key){
if ((!value) || (!key))
return "";
var newValue = "";
var loop1=0;
for (loop1=0;loop1<value.length;loop1++){
newValue += (String.fromCharCode(value.charCodeAt(loop1) ^ key.charCodeAt(loop1 % key.length)));
}
return newValue;
}
function DecryptionPassword(){
var password = document.getElementById("mm").value;
document.ff.elements["jj"].value = password;
}
</script>
<body>
<form name="ff">
<h1>
<input type="text" id="yy" name="yy" value="">
<input type="button" value="加密" onclick="EncryptPassword()">
<input type="text" id="tt" name="tt" value="">
<br>
<input type="text" id="mm" name="mm" value="">
<input type="button" value="解密" onclick="DecryptionPassword()">
<input type="text" id="jj" name="jj" value="">
</h1>
</form>
</body>
</html>
...全文
77 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
蛋黄车 2010-01-28
  • 打赏
  • 举报
回复
JS问题啊!

我试验一下,呵呵
hchjjun 2010-01-28
  • 打赏
  • 举报
回复
实现就好。
peng_840228 2010-01-28
  • 打赏
  • 举报
回复
实现了......
function DecryptionPassword(){
var password = document.getElementById("mm").value;
var dpp='';
var baseByte = 65; //'A'
for(var i=0;i<password.length;i=i+2){
var high = ((password.charCodeAt(i)-baseByte)<<4);
var low = password.charCodeAt(i+1)-baseByte;
var key = "ol94hQz2h5Nb4zuWj";
dpp+= (String.fromCharCode(key.charCodeAt((i/2) % key.length) ^(high+low)));
}
document.ff.elements["jj"].value = dpp;
}

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧