Assignment 10
by Taylor Zimmerman
HTML
<html>
<body>
<fieldset>
<legend>Enter a New password to be hashed</legend>
<input type='textbox' id='NewPassInput'>
<input type='button' value='Add Password' onclick='AddPass();'>
</fieldset>
<fieldset>
<legend>List Passwords</legend>
<div id="output">
</div>
</fieldset><br>
<fieldset>
<legend>Check to see if password alread exists</legend>
<input type="textbox" id="CheckPassInput">
<input type="button" onclick="CheckPass();" value="Check password">
</fieldset>
<fieldset>
<legend>Password Search Result</legend>
<div id="result">
</div>
</fieldset>
</body>
</html>
JavaScript
function Node(content){
content = document.getElementById("NewPassInput").value;
this.next = null;
this.last = null;
this.hash = MD5(content);
return this;
}
function LinkedList(content){
this.head = null;
this.tail = null;
this.length = 0;
return this;
}
LinkedList.prototype.push = function(content){
this.add(content);
}
LinkedList.prototype.add = function(content){
var node = new Node();
node.content = content;
if (this.head === null) {
this.head = node;
this.length = 1;
return node;
}
if (this.tail == null) {
this.tail = node;
this.tail.last = this.head;
this.head.next = this.tail;
this.length++;
return node;
}
this.tail.next = node;
node.last = this.tail;
this.tail = node;
this.length++;
return node;
}
LinkedList.prototype.print = function(){
if (this.head == null) return "Empty List";
var node = this.head;
var d = "";
while(node != null){
d += node.hash + "</br>";
node = node.next;
}
return d;
}
var List = new LinkedList();
function AddPass(){
var content = document.getElementById("NewPassInput").value;
List.push(content);
document.getElementById('output').innerHTML = List.print();
}
/**
*
* MD5 (Message-Digest Algorithm)
* http://www.webtoolkit.info/
*
**/
var MD5 = function (string) {
function RotateLeft(lValue, iShiftBits) {
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
}
function AddUnsigned(lX,lY) {
var lX4,lY4,lX8,lY8,lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
if (lX4 & lY4) {
return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
}
if (lX4 | lY4) {
if (lResult & 0x40000000) {
return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
} else {
...