密码加密,求如何解密
把下列代码,复制到记事本另存为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>