-
Notifications
You must be signed in to change notification settings - Fork 0
/
passwd.html
89 lines (78 loc) · 3.13 KB
/
passwd.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function sha512crypt(password, salt) {
var hash = sha512crypt(password, salt);
return hash;
}
function randomSalt(length) {
var tab="./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var result = '';
for (var i = length; i > 0; --i) {
var buf = new Uint8Array(1);
window.crypto.getRandomValues(buf);
result += tab[parseInt(buf[0].toString(2).slice(0,6),2)];
}
return result;
}
function do_crypt() {
var password = document.forms["pwform"]["password"].value;
var password2 = document.forms["pwform"]["password2"].value;
if (password != password2) {
document.getElementById("pass_error").innerHTML = "passwords do not match";
document.getElementById("hash_p").innerHTML = 'None yet';
return false;
}
document.getElementById("pass_error").innerHTML = "";
var salt = randomSalt(16);
var hash = sha512crypt(password, salt);
document.getElementById("hash_p").innerHTML = hash;
return false;
}
function do_clear() {
document.getElementById("pwform").reset();
document.getElementById("hash_p").innerHTML = 'None yet';
document.getElementById("pass_error").innerHTML = "";
return false;
}
</script>
<script src="dist/sha512.js"></script>
<script src="dist/sha512crypt.js"></script>
<script src="dist/clipboard.min.js"></script>
</head>
<body>
<h1>sha512crypt password</h1>
<p>This page will generate a sha512-crypt hash from a password all within the browser, no passwords or hashes are sent to a server.</p>
<p style="font-size: smaller"><span style="font-weight: bold">DISCALAIMER:</span> THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE</p>
<form id="pwform" name="pwform" action="#" onsubmit="return false;">
<input type="password" name="password" placeholder="password"><br>
<input type="password" name="password2" placeholder="password again" onchange="do_crypt()">
<span id="pass_error" style="color:red"></span>
</form>
<p></p>
<div>Hash:
<pre><span id="hash_p">None yet</span></pre>
<button class="btn" data-clipboard-target="#hash_p">Copy to clipboard</button>
</div>
<p></p>
<button type="button" onclick="do_clear()">Clear</button>
<p>Credits:
<ul>
<li>sha512crypt implementation by mvo5. See https://github.com/mvo5/sha512crypt-node</li>
<li>Copy to clipboard by https://clipboardjs.com/</li>
<li>The rest by https://github.com/trnubo</li>
</ul>
</p>
<script>
var clipboard = new Clipboard('.btn');
clipboard.on('success', function(e) {
console.log(e);
});
clipboard.on('error', function(e) {
console.log(e);
});
</script>
</body>
</html>