<html>
<head>
</head>
<body>
<input type = textbox id = in value = 'Insert Password'><input type = button id = insert_pass onclick = "input()" value = "Submit password" >
<br>
<br>
<input type = textbox id = ch value = 'Check for Password'><input type = button id = search value = 'Search for Password' onclick = search()>
<br><br>
<p id = out>
</body></html>
JavaScript
function SList()
{
this.head = null;
this.tail = null;
this.length = null;
}
function Node(){
this.key = null;
this.next = null;
}
SList.prototype.hash = function (_Key){
var hash = '', i=0,char='';
if (_Key.length ===0){
this.addnode(hash);
}
else{
for (i = 0; i<_Key.length; i++){
char = _Key.charCodeAt(i);
hash = ((hash << 5) - hash)+char;
hash = hash & hash;
}
}
console.log(hash);
return hash;
}
SList.prototype.search = function(_Search){
var search = this.hash(_Search)
var traveler = new Node();
traveler = this.head;
while(traveler){
if(traveler.key == search){globalstring = traveler.key;return 1;}
traveler = traveler.next;
}
return 0;
}
SList.prototype.addnode = function(_Key){
var node = new Node();
node.key = _Key;
if(this.tail==null && this.head ==null){
this.tail = node;
this.head = node;
node.next = null;
this.length ++;
}
else
this.tail.next = node;
this.tail = node;
}
list = new SList();
function input() {
var string = document.getElementById("in").value;
console.log(string);
var hash = 0;
hash = list.hash(string);
list.addnode(hash);
}
var globalstring='';
function search(){
var string = document.getElementById("ch").value;
var bool = -1;
bool = list.search(string);
if(bool > 0){document.getElementById("out").innerHTML = "The Password exists in the list with value " + globalstring }
else{document.getElementById("out").innerHTML = "The phrase you have entered does not exists in the list"}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.