-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
194 lines (169 loc) · 6.23 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<html>
<head>
<title>Hashwords - Hash Passwords that anybody can create.</title>
<link rel="stylesheet" href="ui.tabs.css" type="text/css" media="print, projection, screen">
<script src="md4.js" type="text/javascript"></script>
<script src="md5.js" type="text/javascript"></script>
<script src="sha1.js" type="text/javascript"></script>
<script src="base64.js" type="text/javascript"></script>
<script src="jquery-1.2.6.js" type="text/javascript"></script>
<script src="ui.core.js" type="text/javascript"></script>
<script src="ui.tabs.js" type="text/javascript"></script>
<script src="jquery.cookies.2.0.js" type="text/javascript"></script>
<script type="text/javascript">
var base93="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";\'<>?,./";
var base64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; //RFC 1421
var base62="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var base32="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; //RFC 3548
var base16="0123456789ABCDEF";
var alphanumeric=base62+"MM";
var strong="ABCDEFGHJKLMNPQRSTUVWabcdefghijkmnopqrstuvw0123456789+/-_*()[]{}";
var TIME_UNTIL_EXPIRY = 24 * 7 ; // 7 days
var DEFAULT_LENGTH = "12";
var DEFAULT_HASH = "md5";
var DEFAULT_CHARSET = strong;
function generatePassword() {
var password = "";
var hashAlgorithm = $('#hash').val();
var key = $('#master').val();
var data = $('#url').val();
switch(hashAlgorithm) {
case "sha1":
password = str_sha1(key+data);
break;
case "md4":
password = str_md4(key+data);
break;
case "md5":
password = str_md5(key+data);
break;
}
password = base64_encode(password, $('#charset').val());
password = password.substring(0, $('#length').val());
$('#hashword').val(password);
}
function getDomain(url) {
var current_URL = '';
if (url.indexOf('?') > -1) {
current_URL = unescape(url.substr(url.indexOf('?')+1));
}
if (current_URL == 'localhost')
return current_URL;
if (IsIp(current_URL))
return current_URL;
if (current_URL == '')
return current_URL;
var split = current_URL.split('.'); //location.hostname.split('.');
var domain = [split.pop()];
while (item = split.pop()) {
domain.unshift(item);
if (item.length > 2) {
break;
}
}
return domain.join('.');
}
function IsIp(ip) {
var regexp = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
return regexp.test(ip);
}
function setCharset(charset) {
$("charset").value = charset;
}
$(document).ready(function(){
$('#url').val(getDomain(window.location.href));
$("#example > ul").tabs();
$('#master').cookieBind();
$('#length').val($.cookies.get('length') || DEFAULT_LENGTH);
$('#hash').val($.cookies.get('hash') || DEFAULT_HASH);
$('#charset').val($.cookies.get('charset') || DEFAULT_CHARSET);
$('#main .dynamic').bind('keydown keypress keyup change',function(){
generatePassword();
})
$('#settings .dynamic').change(function(){
generatePassword();
})
$("#settings a").click(function(e){
e.preventDefault();
switch($(this).html()) {
case "AlphaNumeric":
$('#charset').val(alphanumeric);
break;
case "Strong":
$('#charset').val(strong);
break;
}
generatePassword();
});
generatePassword();
$('#master').focus();
});
$(window).unload(function(){
$('#length').cookify({hoursToLive: TIME_UNTIL_EXPIRY});
$('#hash').cookify({hoursToLive: TIME_UNTIL_EXPIRY});
$('#charset').cookify({hoursToLive: TIME_UNTIL_EXPIRY});
});
</script>
</head>
<body>
<div id="example" class="flora">
<ul>
<li><a href="#main"><span>Main</span></a></li>
<li><a href="#settings"><span>Settings</span></a></li>
<li><a href="#bookmarklet"><span>Bookmarklet</span></a></li>
</ul>
<div id="main">
<table cellpadding=5>
<tr>
<td>Master password</td>
<td><input class="dynamic" type="password" id="master" />
</td>
</tr>
<tr id='urlToUseRow'>
<td>URL to use</td>
<td><input class="dynamic" type="text" id="url" /></td>
</tr>
<tr>
<td>Generated Hashword</td>
<td><input id="hashword" type="text" style="color: #0000ff; font-weight: bold"/></td>
</tr>
</table>
</div>
<div id="settings">
<table cellpadding=5>
<tr>
<td>Hash Algorithm</td>
<td>
<select class="dynamic" id="hash" >
<option value="md4">MD4</option>
<option value="md5">MD5</option>
<option value="sha1">SHA-1</option>
</select>
</td>
</tr>
<tr>
<td>Hashword Length</td>
<td><select class="dynamic" id="length">
<option value="8">8</option>
<option value="12">12</option>
<option value="16">16</option>
</select></td>
</tr>
<tr>
<td>Characters</td>
<td>
<a href="#" onClick="setCharset(alphanumeric);return false;">AlphaNumeric</a> |
<a href="#" onClick="setCharset(strong);return false;">Strong</a></br/>
<input class="dynamic" type="text" id="charset"/>
</td></tr>
</table>
</div>
<div id="bookmarklet">
<center>
<p>Generate Hashwords the easy way! Drag this bookmarklet to the Links area of your browser.</p>
<p><a style="border: 2px groove black; padding: 0px 5px 2px; background-color: rgb(221, 221, 221); color: black; font-family: sans-serif; text-decoration: none; font-size: 10pt; margin-top: 5px;" href='javascript:(function(){var a=window,b=document,c=a.open("http://mm53bar.github.io/Hashwords?"+b.location.hostname,"hash_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=200px,width=400px,resizable=1,alwaysRaised=1");a.setTimeout(function(){c.focus()},300)})();'>Hash It!</a></p>
</center>
</div>
</div>
</body>
</html>