-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile2hex.html
More file actions
35 lines (35 loc) · 854 Bytes
/
file2hex.html
File metadata and controls
35 lines (35 loc) · 854 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>File → Hex</title>
</head>
<body>
File → Hex
<div><input type="file" oninput="megnyit();" id="f"></div>
<div><textarea readonly id="t" style="white-space: pre;"></textarea></div>
<script>
var f=document.getElementById("f");
var t=document.getElementById("t");
async function megnyit() {
f.disabled=true;
t.disabled=true;
try {
t.value="";
var ab = await f.files[0].arrayBuffer();
var u8a=new Uint8Array(ab);
var str="";
for(let i=0; i<u8a.length; i++) {
str+=u8a[i].toString(16).padStart(2,"0");
}
t.value=str;
} catch(err) {
console.error(err);alert(err);
} finally {
t.disabled=false;
f.disabled=false;
}
}
</script>
</body>
</html>