-
Notifications
You must be signed in to change notification settings - Fork 0
/
crc32c.html
53 lines (49 loc) · 1.9 KB
/
crc32c.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>crc32c tester</title>
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css"/>
</head>
<body>
<script src="https://cdn.sheetjs.com/crc-32-latest/package/crc32c.js"></script>
<script>
const keys = [
0xa8770416, 0xa98beb34, 0xb29b1d90, 0xd5354502, 0xce9df055, 0xe3230e2f,
0xe1dd1d34, 0xbd530797, 0xa2c7c909, 0xa047885e, 0x9b274d93, 0x7d86e792,
0x078ac8bd, 0x6c836947, 0x66ebfad1, 0x66df165f, 0x65e740d3, 0x65d75204,
0x4bb0092c, 0x442a34ac, 0x2ec0e736, 0x2c3ef42d, 0x27424d58, 0x1a081a93,
0x15e90814,
];
function handleInput() {
const input = document.getElementById("input");
const output = document.getElementById("output");
const outputLowercase = document.getElementById("outputLowercase");
if (input.value.length === 0) {
output.innerText = "0x00000000";
outputLowercase.innerText = "0x00000000";
return;
}
const result = CRC32C.str(input.value) >>> 0;
const resultLowercase = CRC32C.str(input.value.toLowerCase()) >>> 0;
output.innerText = "0x" + result.toString(16);
outputLowercase.innerText = "0x" + resultLowercase.toString(16);
if (keys.includes(result)) {
log.innerText += `\n${result} - ${input.value}`;
}
if (keys.includes(resultLowercase)) {
log.innerText += `\n${resultLowercase} - ${input.value.toLowerCase()}`;
}
}
</script>
<p></p>
<label for="input">Input</label>
<input type="text" id="input" oninput="handleInput()"/>
<label for="output">Output</label>
<pre id="output">0x00000000</pre>
<label for="outputLowercase">Output (lowercase)</label>
<pre id="outputLowercase">0x00000000</pre>
<pre id="log">Found:</pre>
</body>
</html>