####
##
function sendLogin()
{
// If the 'data' variable is not defined then there was probably some
// problem with loading the page. The best guess is that the user's network
// connection has gone down. Inform the user and try to reload the page.
if (typeof(data) == "undefined") {
alert ("The network connection seems to be down. Press 'Ok' to try again.");
location.reload(true);
return;
}
var a = new Array;
// Compute the login hash.
var shex = byteArrayToHexString(convertFromBase64(data),0,4);
var goodp = document.myform.Password.value.substr(0,16);
document.myform.Password.value = ""; // Make sure password never gets sent as clear text
for (var i = goodp.length; i < 16; i++) {
goodp = goodp.concat(String.fromCharCode(1));
}
var str = shex + goodp;
// Pad the string to 64 bytes.
for (var i = str.length; i < 63; i++) {
str = str.concat(String.fromCharCode(1));
}
str = str.concat((document.myform.username.value == 'user') ? 'U' : String.fromCharCode(1));
var hash = hex_md5(str);
var saltHash = shex.concat(hash);
a = convertHexString(saltHash, 20, 20);
// Send the new configuration to the server
sendDataToServer ("post_login.cgi?data=" + convertToBase64(a),loginReturnValue)
}