-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
37 lines (36 loc) · 1.29 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
<html>
<head>
<title>Salasanageneraattori</title>
</head>
<body>
<pre id="pwds" style="line-height: 2.0">Ladataan kotus_sanat.txt...</pre>
<button id="generate" onclick="generate(10, 3)" disabled>Lisää salasanoja</button>
<hr/>
<a href="https://github.com/dancek/kotus-pwgen">Source code and other implementations on GitHub</a>
<script>
fetch('./kotus_sanat.txt')
.then(response => response.text())
.then(text => text.split('\n'))
.then(lines => {
// modifying global state
document.getElementById('generate').removeAttribute('disabled')
window.wordlist = lines
generate(10, 3)
})
function generate(pwd_count, pwd_len) {
var pwds = []
for (var i = pwd_count + 1; --i;) {
var pwd_words = []
for (var j = pwd_len + 1; --j;) {
const pos = Math.floor(Math.random() * wordlist.length)
const word = wordlist[pos]
pwd_words.push(word)
}
const pwd = pwd_words.join(' ')
pwds.push(pwd)
}
document.getElementById('pwds').innerText = pwds.join('\n')
}
</script>
</body>
</html>