-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
62 lines (57 loc) · 1.4 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
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<meta name='description' content='Calculate the checksum of a file using JavaScript.' />
<meta name='viewport' content='width=device-width' />
<title>csum</title>
<style>
body {
padding: 0 20px;
max-width: 800px;
margin: auto;
word-break: break-word;
}
body, select, input {
font-family: sans-serif;
}
h1, p {
margin: 10px 0;
}
</style>
<script type='module'>
import { csum } from './csum.js'
const select = document.querySelector('select')
const input = document.querySelector('input')
const handle = async () =>
{
for (const file of input.files)
{
const code = document.createElement('code')
const checksum = await csum(file, select.value)
code.textContent = checksum
const p = document.createElement('p')
p.textContent = `${file.name}'s ${select.value} checksum is: `
p.append(code)
document.body.append(p)
}
}
select.addEventListener('change', handle)
input.addEventListener('change', handle)
</script>
</head>
<body>
<h1>csum</h1>
<p>Calculate the checksum of a file using JavaScript.</p>
<label>
Algorithm:
<select>
<option>SHA-1</option>
<option selected>SHA-256</option>
<option>SHA-384</option>
<option>SHA-512</option>
</select>
</label>
<input type='file' multiple />
</body>
</html>