-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
72 lines (70 loc) · 2.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hex Converter</title>
<style>
body {
font-family: 'Arial', sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
text-align: center;
}
.container {
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
}
input, button {
padding: 10px;
border-radius: 5px;
border: none;
margin-top: 10px;
}
input {
width: calc(100% - 24px);
}
button {
cursor: pointer;
background-color: #4CAF50; /* Green */
color: white;
width: 100%;
}
button:hover {
background-color: #45a049;
}
.result {
margin-top: 20px;
word-wrap: break-word;
}
</style>
</head>
<body>
<div class="container">
<h2>Hex to Little Endian Converter</h2>
<input id="hexInput" type="text" placeholder="Enter hex string">
<button onclick="convertAndDisplay()">Convert</button>
<div class="result" id="result"></div>
</div>
<script>
function littleEndianToNumber(hexString) {
const byteArray = hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16));
const bigEndianArray = byteArray.reverse();
const bigEndianHexString = bigEndianArray.map(byte => byte.toString(16).padStart(2, '0')).join('');
return parseInt(bigEndianHexString, 16);
}
function convertAndDisplay() {
const hexString = document.getElementById('hexInput').value;
const result = littleEndianToNumber(hexString);
document.getElementById('result').innerText = 'Result: ' + result;
}
</script>
</body>
</html>