-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
75 lines (63 loc) · 2.42 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
<html>
<head>
<title>Passhash</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="icon" href="favicon.ico" type="image/x-icon" />
</head>
<body>
<h1><PASSHASH/></h1>
<form onsubmit="hashcopy();" action="javascript:void(0);">
<input id="password" type="password" autofocus>
</form>
<span id="visual"></span>
<span id="notification">COPIED TO CLIPBOARD</span>
<div class="scan-lines">
<div></div>
</div>
<script>
const input = document.getElementById("password");
const visual = document.getElementById("visual");
const notification = document.getElementById("notification");
input.onblur = input.focus;
input.oninput = () => visual.textContent = "#".repeat(input.value.length);
var blink = true;
setInterval(() => {
if (!visual.textContent || visual.textContent == "▮")
visual.textContent = blink ? "▮" : ""
blink = !blink;
}, 500);
document.onkeydown = (e) => {
if (e.key == "F2") {
window.localStorage.setItem("color", window.localStorage.getItem("color") == "green" ? "amber" : "green");
color();
};
};
function color() {
const color = window.localStorage.getItem("color")
document.documentElement.style.setProperty('--phosphor', color == "amber" ? '#ffcc33' : "#6fc38e");
document.documentElement.style.setProperty('--phosphor-bloom', color == "amber" ? '#ffcc3388' : "#6fc38e88");
};
color();
const SYMBOLS = `!"#$%&'()*+,-./:;=?@[\\]^_\`{|}~` //30
const UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //26
const LOWERCASE = "abcdefghijklmnopqrstuvwxyz"; //26
async function hashcopy() {
const encoder = new TextEncoder();
const data = encoder.encode(input.value);
const hash = new Uint8Array(await window.crypto.subtle.digest('SHA-256', data));
var passhash = "";
for (var i = 0; i < 16 + hash[0] % 5; i++) {
passhash += String.fromCharCode(hash[i] % 93 + 33);
}
passhash += SYMBOLS[hash[i++] % 30] + UPPERCASE[hash[i++] % 26] + hash[i++] % 10 + LOWERCASE[hash[i] % 26];
navigator.clipboard.writeText(passhash);
input.value = "";
visual.textContent = "";
notification.style.opacity = 1;
setTimeout(() => { notification.style.opacity = 0 }, 2000);
};
</script>
</body>
</html>