Password Hashing
The first step of this assignment will be to create a List. You may use any List that you have already created. For the purposes of this assignment it does not matter if your list is a doubly linked list of a singly linked list. I recommend that if you created a good useful list in the previous lists assignment use this list. Next you will need to research and find a suitable Hash function. Here are some hash function. You also need to know what a Hash function is. Here is the simple version. Put in A (any length) and get out B (fixed length). If the input is the same, the output is always the same. The probability of an output B being the same for multiple inputs A is a direct function of the length of B and the number of characters in B.
by Neil Daley
HTML
<H2>
Hashing
</H2>
This project will test hashing capabilities. I was able to locate Adler-32 with some research. <br/><br/>As it is stated:<br/><br/>
"<b>Adler-32</b> is a checksum algorithm which was invented by Mark Adler in 1995,[1] and is a modification of the Fletcher checksum. Compared to a cyclic redundancy check of the same length, it trades reliability for speed (preferring the latter). Adler-32 is more reliable than Fletcher-16, and slightly less reliable than Fletcher-32. <font color="blue">(https://en.wikipedia.org/wiki/Adler-32)</font>"
<br/><br/>
<input type="textbox" id="inptStrPw" value="abcde" />
<input type="button" id="btnStore" value="Store Password" onClick="createList()" style="color:white; background-color:blue" />
<input type="textbox" id="inptChkPw" value="abcde" />
<input type="button" id="btnCheck" value="Check Password" onClick="pwCheck()" style="color:white; background-color:blue" />
<br/><br/>
<div id="output"></div><br/>
<div id="output2"></div>
JavaScript
// New doubly linked list
var dll = function(_content) {
this.head = null;
this.tail = null;
this.length = 0;
return this;
};
// New node creation, passing the value of user input
function myNode(_content) {
_content = document.getElementById("inptStrPw").value;
this.next = null;
this.prev = null;
this.hshKey = storeHsh(_content);
return this;
}
// Adds new node to list
dll.prototype.add = function(_content) {
var node = new myNode();
node._content = _content;
if (this.head == null) {
this.head = node;
this.length = 1;
return node;
}
if (this.tail == null) {
this.tail = node;
this.tail.prev = this.head;
this.head.next = this.tail;
this.length++;
return node;
}
this.tail.next = node;
node.prev = this.tail;
this.tail = node;
this.length++;
return node;
}
dll.prototype.toString = function() {
if (this.head == null) return "Empty List";
var str = "";
var node = this.head;
while (node != null) {
str += node.hshKey + "<br/>";
node = node.next;
}
return str;
}
// New doubly linked list 'list'
var list = new dll();
// When called, the user input is storeduusing the add function
function createList() {
var _content = document.getElementById("inptStrPw").value;
list.add(_content); // passing user input
document.getElementById("output").innerHTML = list.toString();
document.getElementById("inptStrPw").value = ''; // clears text box
document.getElementById("inptStrPw").select(); // paces cursor in textbox
}
// Adler32
// https://en.wikipedia.org/wiki/Adler-32
function storeHsh (_content) {
var MOD_ADLER = 65521;
var a = 1,
b = 0;
for (var i = 0; i < _content.length; i++) {
a = (a + _content.charCodeAt(i)) %...