-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncoding-Decoding.html
More file actions
102 lines (89 loc) · 3.21 KB
/
Encoding-Decoding.html
File metadata and controls
102 lines (89 loc) · 3.21 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Encoding and Decoding</title>
<style>
body {
font-family: Arial, sans-serif;
}
.tab-content {
display: none;
}
.active {
display: block;
}
.tab-button {
cursor: pointer;
}
textarea {
width: 100%;
height: 150px;
}
</style>
</head>
<body>
<h1>Encoding and Decoding</h1>
<div class="tab-button" onclick="openTab('Base64')">Base64</div>
<div class="tab-button" onclick="openTab('HEX')">HEX</div>
<div class="tab-button" onclick="openTab('HexDump')">HexDump</div>
<div class="tab-button" onclick="openTab('URL')">URL</div>
<div id="Base64" class="tab-content active">
<h2>Base64 Encoding and Decoding</h2>
<textarea id="base64Input" placeholder="Enter text"></textarea>
<button onclick="encodeBase64()">Encode</button>
<button onclick="decodeBase64()">Decode</button>
<h3>Result:</h3>
<div id="base64Result"></div>
</div>
<div id="HEX" class="tab-content">
<h2>HEX Encoding and Decoding</h2>
<textarea id="hexInput" placeholder="Enter text"></textarea>
<button onclick="encodeHEX()">Encode</button>
<button onclick="decodeHEX()">Decode</button>
<h3>Result:</h3>
<div id="hexResult"></div>
</div>
<div id="HexDump" class="tab-content">
<h2>HexDump Encoding and Decoding</h2>
<textarea id="hexDumpInput" placeholder="Enter text"></textarea>
<button onclick="encodeHexDump()">Encode</button>
<button onclick="decodeHexDump()">Decode</button>
<h3>Result:</h3>
<div id="hexDumpResult"></div>
</div>
<div id="URL" class="tab-content">
<h2>URL Encoding and Decoding</h2>
<textarea id="urlInput" placeholder="Enter text"></textarea>
<button onclick="encodeURL()">Encode</button>
<button onclick="decodeURL()">Decode</button>
<h3>Result:</h3>
<div id="urlResult"></div>
</div>
<script>
function openTab(tabName) {
const tabs = document.getElementsByClassName("tab-content");
for (const tab of tabs) {
tab.classList.remove("active");
}
document.getElementById(tabName).classList.add("active");
}
function encodeBase64() {
const input = document.getElementById("base64Input").value;
const result = btoa(input);
document.getElementById("base64Result").textContent = result;
}
function decodeBase64() {
const input = document.getElementById("base64Input").value;
try {
const result = atob(input);
document.getElementById("base64Result").textContent = result;
} catch (error) {
document.getElementById("base64Result").textContent = "Invalid Base64 input.";
}
}
// Implement similar functions for other encoding and decoding types (HEX, HexDump, URL).
</script>
</body>
</html>