-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
176 lines (159 loc) · 6.96 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
<!DOCTYPE HTML>
<html>
<head>
<title>Hashgen</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="//cdn.jsdelivr.net/sjcl/1.0.2/sjcl.js" integrity="sha384-M7t6M9YoRxVW+BM9T6HIy8W4k/QPCdc4Hcc4ypxcWEy2wn/S/x3M4+E6xBQWEmEP" crossorigin="anonymous"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/js-sha1/0.3.0/sha1.min.js" integrity="sha384-qqWvHRx8zl79bsQNpQ/4GYSHa95q2G5AnQuSqtZXX4ojp9ag+aCPjMAP51ujFByC" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--[if lt IE 9 ]>
<script>
var is_ie_lt9 = true;
</script>
<![endif]-->
<script>
function doHash() {
document.getElementById("hash").setAttribute("value", '{SHA}'+ sjcl.codec.base64.fromBits(sjcl.codec.hex.toBits(sha1(document.getElementById("password").value))));
}
//function getSalt(len) {
// return sjcl.random.randomWords(ceil(len * 3 / 4 / 4 )) // length in base64 chars, 4 bytes per word
//}
function doSHA256() {
document.getElementById("hash2").setAttribute("value", sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(document.getElementById("password2").value)));
}
jQuery(document).ready(function(){
//var buf = crypto.randomBytes(1024/8)
//buf = new Uint32Array(new Uint8Array(buf).buffer)
//sjcl.random.addEntropy(buf,1024,"crypto.randomBytes")
var tabItems = $('.cd-tabs-navigation a'),
tabContentWrapper = $('.cd-tabs-content');
tabItems.on('click', function(event){
event.preventDefault();
var selectedItem = $(this);
if( !selectedItem.hasClass('selected') ) {
var selectedTab = selectedItem.data('content'),
selectedContent = tabContentWrapper.find('li[data-content="'+selectedTab+'"]'),
selectedContentHeight = selectedContent.innerHeight();
tabItems.removeClass('selected');
selectedItem.addClass('selected');
selectedContent.addClass('selected').siblings('li').removeClass('selected');
window.location = $(this).attr("href");
//animate tabContentWrapper height when content changes
tabContentWrapper.animate({
'height': selectedContentHeight
}, 200);
}
});
$('a[href="'+window.location.hash+'"]').trigger("click");
if (window.location.hash) {
$('.cd-tabs-navigation').hide();
}
});
</script>
<style>
body { padding: 1em; }
.cd-tabs {
position: relative;
margin: 2em auto;
}
.cd-tabs:after {
content: "";
display: table;
clear: both;
}
.no-cssgradients .cd-tabs::after {
display: none;
}
.cd-tabs nav {
overflow: auto;
-webkit-overflow-scrolling: touch;
background: #f8f7ee;
box-shadow: inset 0 -2px 3px rgba(203, 196, 130, 0.06);
}
.cd-tabs-navigation:after {
content: "";
display: table;
clear: both;
}
.cd-tabs-navigation li {
float: left;
list-style-type: none;
}
.cd-tabs-navigation a {
position: relative;
display: block;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #c3c2b9;
}
.cd-tabs-navigation a.selected {
box-shadow: inset 0px 0px 3px rgba(0, 0, 0, 1);
}
.cd-tabs-navigation a::before {
/* icons */
position: absolute;
top: 12px;
left: 50%;
margin-left: -10px;
display: inline-block;
height: 20px;
width: 20px;
background-repeat: no-repeat;
}
.cd-tabs-navigation a[data-content='sha1']::before {
background-position: 0 0;
}
.cd-tabs-navigation a[data-content='sha256']::before {
background-position: -20px 0;
}
.cd-tabs-content li {
display: none;
padding: 1.4em;
}
.cd-tabs-content li.selected {
display: block;
}
</style>
<link rel="stylesheet" href="//yui-s.yahooapis.com/pure/0.6.0/base-min.css">
<link rel="stylesheet" href="//yui-s.yahooapis.com/pure/0.6.0/pure-min.css">
</head>
<body>
<div class="cd-tabs">
<h1>Hashgen</h1>
<p>Clientside hashing. Libraries from CDN's. No data is sent to the server. No warranties of merchantability or fitness for a particular purpose. Code at <a href="https://github.com/cjdmax/hashgen">github.com/cjdmax/hashgen</a></p>
<nav><ul class="cd-tabs-navigation">
<li><a class="pure-button pure-button-primary" data-content="sha1" class="selected" href="#sha1">SHA1/Base64</a></li>
<li><a class="pure-button pure-button-primary" data-content="sha256" href="#sha2">SHA256/Base64</a></li>
</ul></nav>
<ul class="cd-tabs-content">
<li data-content="sha1" class="selected">
<form class="pure-form pure-form-aligned"><fieldset>
<legend>SHA1 / Base64</legend>
<div class="pure-control-group">
<label class="field" for="password">Password:</label><input type="password" onInput="doHash()" class="pure-input-2-3" name="password" id="password" autofocus inputmode="verbatim" placeholder="enter a password" />
</div>
<div class="pure-control-group">
<label class="field" for="hash">Resulting Hash:</label><input type="text" name="hash" class="pure-input-2-3" id="hash" readonly />
</div>
<p>Or execute the following on the linux commandline <tt>echo -n mypassword | openssl dgst -binary -sha1 | openssl base64</tt></p>
<p>Unsalted SHA1 is not particularly secure; only use for passwords of low importance</p>
</fieldset>
</form>
</li>
<li data-content="sha256">
<form class="pure-form pure-form-aligned"><fieldset>
<legend>SHA-256/ base64</legend>
<div class="pure-control-group">
<label class="field" for="password2">Password:</label><input type="password" onInput="doSHA256()" class="pure-input-2-3" name="password2" id="password2" inputmode="verbatim" placeholder="enter a password" />
</div>
<div class="pure-control-group">
<label class="field" for="hash2">Resulting Hash:</label><input type="text" name="hash2" class="pure-input-2-3" id="hash2" readonly />
</div>
<p>If you have Python 3 available, use <tt>python3 -c 'import crypt; print(crypt.crypt("yourpassword", crypt.mksalt(crypt.METHOD_SHA256)))'</tt> on the linux commandline.</p>
</fieldset>
</form>
</li>
</ul>
</div>
</body>
</html>