Spaces:
Running
Running
Add 2 files
Browse files- README.md +6 -4
- index.html +396 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: green
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: codecipher
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: gray
|
| 5 |
colorTo: green
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,396 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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title>Encode/Decode Tool</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.gradient-bg {
|
| 11 |
+
background: linear-gradient(135deg, #6b73ff 0%, #000dff 100%);
|
| 12 |
+
}
|
| 13 |
+
.text-gradient {
|
| 14 |
+
background: linear-gradient(90deg, #ff8a00, #e52e71);
|
| 15 |
+
-webkit-background-clip: text;
|
| 16 |
+
background-clip: text;
|
| 17 |
+
color: transparent;
|
| 18 |
+
}
|
| 19 |
+
.result-box {
|
| 20 |
+
min-height: 150px;
|
| 21 |
+
transition: all 0.3s ease;
|
| 22 |
+
}
|
| 23 |
+
.result-box.expanded {
|
| 24 |
+
min-height: 250px;
|
| 25 |
+
}
|
| 26 |
+
.tab-active {
|
| 27 |
+
border-bottom: 3px solid #4f46e5;
|
| 28 |
+
color: #4f46e5;
|
| 29 |
+
font-weight: 600;
|
| 30 |
+
}
|
| 31 |
+
.copy-btn {
|
| 32 |
+
transition: all 0.2s ease;
|
| 33 |
+
}
|
| 34 |
+
.copy-btn:hover {
|
| 35 |
+
transform: scale(1.05);
|
| 36 |
+
}
|
| 37 |
+
.copy-btn:active {
|
| 38 |
+
transform: scale(0.95);
|
| 39 |
+
}
|
| 40 |
+
</style>
|
| 41 |
+
</head>
|
| 42 |
+
<body class="bg-gray-100 min-h-screen">
|
| 43 |
+
<div class="gradient-bg text-white py-6 shadow-lg">
|
| 44 |
+
<div class="container mx-auto px-4">
|
| 45 |
+
<div class="flex items-center justify-between">
|
| 46 |
+
<div class="flex items-center space-x-3">
|
| 47 |
+
<i class="fas fa-lock text-3xl"></i>
|
| 48 |
+
<h1 class="text-2xl md:text-3xl font-bold">Code<span class="text-yellow-300">Cipher</span></h1>
|
| 49 |
+
</div>
|
| 50 |
+
<div class="hidden md:flex space-x-4">
|
| 51 |
+
<a href="#" class="hover:text-yellow-200 transition">Home</a>
|
| 52 |
+
<a href="#" class="hover:text-yellow-200 transition">About</a>
|
| 53 |
+
<a href="#" class="hover:text-yellow-200 transition">Tools</a>
|
| 54 |
+
</div>
|
| 55 |
+
<button class="md:hidden text-xl">
|
| 56 |
+
<i class="fas fa-bars"></i>
|
| 57 |
+
</button>
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
|
| 62 |
+
<div class="container mx-auto px-4 py-8 max-w-6xl">
|
| 63 |
+
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
|
| 64 |
+
<div class="p-6">
|
| 65 |
+
<h2 class="text-2xl font-bold text-gray-800 mb-2">Encoding & Decoding Tool</h2>
|
| 66 |
+
<p class="text-gray-600 mb-6">Convert between different encoding formats quickly and securely</p>
|
| 67 |
+
|
| 68 |
+
<div class="flex space-x-4 border-b mb-6">
|
| 69 |
+
<button id="encode-tab" class="tab-active px-4 py-2">Encode</button>
|
| 70 |
+
<button id="decode-tab" class="px-4 py-2 text-gray-600 hover:text-gray-800">Decode</button>
|
| 71 |
+
</div>
|
| 72 |
+
|
| 73 |
+
<div class="mb-6">
|
| 74 |
+
<label for="method" class="block text-sm font-medium text-gray-700 mb-2">Encoding Method</label>
|
| 75 |
+
<select id="method" class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
| 76 |
+
<option value="base64">Base64</option>
|
| 77 |
+
<option value="url">URL Encoding</option>
|
| 78 |
+
<option value="html">HTML Entities</option>
|
| 79 |
+
<option value="hex">Hexadecimal</option>
|
| 80 |
+
<option value="binary">Binary</option>
|
| 81 |
+
<option value="rot13">ROT13</option>
|
| 82 |
+
</select>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
<div class="mb-6">
|
| 86 |
+
<label for="input-text" class="block text-sm font-medium text-gray-700 mb-2">Input Text</label>
|
| 87 |
+
<textarea id="input-text" rows="5" class="w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Enter text to encode/decode..."></textarea>
|
| 88 |
+
</div>
|
| 89 |
+
|
| 90 |
+
<div class="flex space-x-4 mb-6">
|
| 91 |
+
<button id="process-btn" class="flex-1 bg-blue-600 hover:bg-blue-700 text-white py-3 px-6 rounded-lg font-medium transition flex items-center justify-center">
|
| 92 |
+
<i class="fas fa-cog mr-2"></i> Process
|
| 93 |
+
</button>
|
| 94 |
+
<button id="clear-btn" class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-800 py-3 px-6 rounded-lg font-medium transition flex items-center justify-center">
|
| 95 |
+
<i class="fas fa-trash-alt mr-2"></i> Clear
|
| 96 |
+
</button>
|
| 97 |
+
</div>
|
| 98 |
+
|
| 99 |
+
<div class="bg-gray-50 p-4 rounded-lg result-box" id="result-container">
|
| 100 |
+
<div class="flex justify-between items-center mb-3">
|
| 101 |
+
<h3 class="font-medium text-gray-700">Result</h3>
|
| 102 |
+
<div class="flex space-x-2">
|
| 103 |
+
<button id="copy-btn" class="copy-btn bg-blue-100 text-blue-600 p-2 rounded-lg hover:bg-blue-200">
|
| 104 |
+
<i class="fas fa-copy"></i>
|
| 105 |
+
</button>
|
| 106 |
+
<button id="expand-btn" class="copy-btn bg-gray-200 text-gray-600 p-2 rounded-lg hover:bg-gray-300">
|
| 107 |
+
<i class="fas fa-expand"></i>
|
| 108 |
+
</button>
|
| 109 |
+
</div>
|
| 110 |
+
</div>
|
| 111 |
+
<div id="result" class="text-gray-800 whitespace-pre-wrap break-words"></div>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<div class="bg-gray-50 px-6 py-4 border-t">
|
| 116 |
+
<h3 class="font-medium text-gray-700 mb-2">About Encoding Methods</h3>
|
| 117 |
+
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 text-sm text-gray-600">
|
| 118 |
+
<div class="bg-white p-3 rounded-lg shadow-sm">
|
| 119 |
+
<h4 class="font-medium text-blue-600 mb-1">Base64</h4>
|
| 120 |
+
<p>Encodes binary data to ASCII characters. Commonly used for email attachments and embedding images in HTML.</p>
|
| 121 |
+
</div>
|
| 122 |
+
<div class="bg-white p-3 rounded-lg shadow-sm">
|
| 123 |
+
<h4 class="font-medium text-blue-600 mb-1">URL Encoding</h4>
|
| 124 |
+
<p>Replaces unsafe ASCII characters with "%" followed by hexadecimal digits. Used in URLs.</p>
|
| 125 |
+
</div>
|
| 126 |
+
<div class="bg-white p-3 rounded-lg shadow-sm">
|
| 127 |
+
<h4 class="font-medium text-blue-600 mb-1">HTML Entities</h4>
|
| 128 |
+
<p>Represents special characters in HTML to prevent parsing issues and XSS attacks.</p>
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
<div class="mt-8 bg-white rounded-xl shadow-lg overflow-hidden">
|
| 135 |
+
<div class="p-6">
|
| 136 |
+
<h2 class="text-xl font-bold text-gray-800 mb-4">Recent Conversions</h2>
|
| 137 |
+
<div class="overflow-x-auto">
|
| 138 |
+
<table class="min-w-full divide-y divide-gray-200">
|
| 139 |
+
<thead class="bg-gray-50">
|
| 140 |
+
<tr>
|
| 141 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Method</th>
|
| 142 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Input</th>
|
| 143 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Result</th>
|
| 144 |
+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Time</th>
|
| 145 |
+
</tr>
|
| 146 |
+
</thead>
|
| 147 |
+
<tbody class="bg-white divide-y divide-gray-200" id="history-table">
|
| 148 |
+
<!-- History items will be added here -->
|
| 149 |
+
</tbody>
|
| 150 |
+
</table>
|
| 151 |
+
</div>
|
| 152 |
+
<div class="mt-4 text-center text-sm text-gray-500" id="empty-history">
|
| 153 |
+
No recent conversions. Start encoding/decoding to see history here.
|
| 154 |
+
</div>
|
| 155 |
+
</div>
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
|
| 159 |
+
<footer class="bg-gray-800 text-white py-8 mt-12">
|
| 160 |
+
<div class="container mx-auto px-4">
|
| 161 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
| 162 |
+
<div>
|
| 163 |
+
<h3 class="text-xl font-bold mb-4">CodeCipher</h3>
|
| 164 |
+
<p class="text-gray-400">A powerful tool for all your encoding and decoding needs. Fast, secure, and easy to use.</p>
|
| 165 |
+
</div>
|
| 166 |
+
<div>
|
| 167 |
+
<h3 class="text-xl font-bold mb-4">Quick Links</h3>
|
| 168 |
+
<ul class="space-y-2">
|
| 169 |
+
<li><a href="#" class="text-gray-400 hover:text-white transition">Home</a></li>
|
| 170 |
+
<li><a href="#" class="text-gray-400 hover:text-white transition">About</a></li>
|
| 171 |
+
<li><a href="#" class="text-gray-400 hover:text-white transition">Privacy Policy</a></li>
|
| 172 |
+
</ul>
|
| 173 |
+
</div>
|
| 174 |
+
<div>
|
| 175 |
+
<h3 class="text-xl font-bold mb-4">Connect</h3>
|
| 176 |
+
<div class="flex space-x-4">
|
| 177 |
+
<a href="#" class="text-gray-400 hover:text-white transition text-xl"><i class="fab fa-twitter"></i></a>
|
| 178 |
+
<a href="#" class="text-gray-400 hover:text-white transition text-xl"><i class="fab fa-github"></i></a>
|
| 179 |
+
<a href="#" class="text-gray-400 hover:text-white transition text-xl"><i class="fab fa-linkedin"></i></a>
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
<div class="border-t border-gray-700 mt-8 pt-6 text-center text-gray-400">
|
| 184 |
+
<p>© 2023 CodeCipher. All rights reserved.</p>
|
| 185 |
+
</div>
|
| 186 |
+
</div>
|
| 187 |
+
</footer>
|
| 188 |
+
|
| 189 |
+
<script>
|
| 190 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 191 |
+
// DOM elements
|
| 192 |
+
const encodeTab = document.getElementById('encode-tab');
|
| 193 |
+
const decodeTab = document.getElementById('decode-tab');
|
| 194 |
+
const methodSelect = document.getElementById('method');
|
| 195 |
+
const inputText = document.getElementById('input-text');
|
| 196 |
+
const processBtn = document.getElementById('process-btn');
|
| 197 |
+
const clearBtn = document.getElementById('clear-btn');
|
| 198 |
+
const resultContainer = document.getElementById('result-container');
|
| 199 |
+
const result = document.getElementById('result');
|
| 200 |
+
const copyBtn = document.getElementById('copy-btn');
|
| 201 |
+
const expandBtn = document.getElementById('expand-btn');
|
| 202 |
+
const historyTable = document.getElementById('history-table');
|
| 203 |
+
const emptyHistory = document.getElementById('empty-history');
|
| 204 |
+
|
| 205 |
+
let isEncoding = true;
|
| 206 |
+
let conversionHistory = JSON.parse(localStorage.getItem('conversionHistory')) || [];
|
| 207 |
+
|
| 208 |
+
// Initialize
|
| 209 |
+
updateHistoryTable();
|
| 210 |
+
|
| 211 |
+
// Tab switching
|
| 212 |
+
encodeTab.addEventListener('click', function() {
|
| 213 |
+
isEncoding = true;
|
| 214 |
+
encodeTab.classList.add('tab-active');
|
| 215 |
+
decodeTab.classList.remove('tab-active');
|
| 216 |
+
processBtn.innerHTML = '<i class="fas fa-cog mr-2"></i> Encode';
|
| 217 |
+
});
|
| 218 |
+
|
| 219 |
+
decodeTab.addEventListener('click', function() {
|
| 220 |
+
isEncoding = false;
|
| 221 |
+
decodeTab.classList.add('tab-active');
|
| 222 |
+
encodeTab.classList.remove('tab-active');
|
| 223 |
+
processBtn.innerHTML = '<i class="fas fa-cog mr-2"></i> Decode';
|
| 224 |
+
});
|
| 225 |
+
|
| 226 |
+
// Process button
|
| 227 |
+
processBtn.addEventListener('click', function() {
|
| 228 |
+
const method = methodSelect.value;
|
| 229 |
+
const text = inputText.value.trim();
|
| 230 |
+
|
| 231 |
+
if (!text) {
|
| 232 |
+
alert('Please enter some text to process');
|
| 233 |
+
return;
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
let processedText;
|
| 237 |
+
|
| 238 |
+
if (isEncoding) {
|
| 239 |
+
processedText = encodeText(text, method);
|
| 240 |
+
} else {
|
| 241 |
+
processedText = decodeText(text, method);
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
result.textContent = processedText;
|
| 245 |
+
|
| 246 |
+
// Add to history
|
| 247 |
+
addToHistory(method, text, processedText);
|
| 248 |
+
});
|
| 249 |
+
|
| 250 |
+
// Clear button
|
| 251 |
+
clearBtn.addEventListener('click', function() {
|
| 252 |
+
inputText.value = '';
|
| 253 |
+
result.textContent = '';
|
| 254 |
+
});
|
| 255 |
+
|
| 256 |
+
// Copy button
|
| 257 |
+
copyBtn.addEventListener('click', function() {
|
| 258 |
+
if (!result.textContent) return;
|
| 259 |
+
|
| 260 |
+
navigator.clipboard.writeText(result.textContent)
|
| 261 |
+
.then(() => {
|
| 262 |
+
const originalIcon = copyBtn.innerHTML;
|
| 263 |
+
copyBtn.innerHTML = '<i class="fas fa-check"></i>';
|
| 264 |
+
setTimeout(() => {
|
| 265 |
+
copyBtn.innerHTML = originalIcon;
|
| 266 |
+
}, 2000);
|
| 267 |
+
})
|
| 268 |
+
.catch(err => {
|
| 269 |
+
console.error('Failed to copy text: ', err);
|
| 270 |
+
});
|
| 271 |
+
});
|
| 272 |
+
|
| 273 |
+
// Expand button
|
| 274 |
+
expandBtn.addEventListener('click', function() {
|
| 275 |
+
resultContainer.classList.toggle('expanded');
|
| 276 |
+
if (resultContainer.classList.contains('expanded')) {
|
| 277 |
+
expandBtn.innerHTML = '<i class="fas fa-compress"></i>';
|
| 278 |
+
} else {
|
| 279 |
+
expandBtn.innerHTML = '<i class="fas fa-expand"></i>';
|
| 280 |
+
}
|
| 281 |
+
});
|
| 282 |
+
|
| 283 |
+
// Encoding/Decoding functions
|
| 284 |
+
function encodeText(text, method) {
|
| 285 |
+
switch(method) {
|
| 286 |
+
case 'base64':
|
| 287 |
+
return btoa(unescape(encodeURIComponent(text)));
|
| 288 |
+
case 'url':
|
| 289 |
+
return encodeURIComponent(text);
|
| 290 |
+
case 'html':
|
| 291 |
+
return text.split('').map(c => `&#${c.charCodeAt(0)};`).join('');
|
| 292 |
+
case 'hex':
|
| 293 |
+
return text.split('').map(c => c.charCodeAt(0).toString(16)).join(' ');
|
| 294 |
+
case 'binary':
|
| 295 |
+
return text.split('').map(c => c.charCodeAt(0).toString(2).padStart(8, '0')).join(' ');
|
| 296 |
+
case 'rot13':
|
| 297 |
+
return text.replace(/[a-zA-Z]/g, function(c) {
|
| 298 |
+
return String.fromCharCode((c <= 'Z' ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
|
| 299 |
+
});
|
| 300 |
+
default:
|
| 301 |
+
return text;
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
function decodeText(text, method) {
|
| 306 |
+
try {
|
| 307 |
+
switch(method) {
|
| 308 |
+
case 'base64':
|
| 309 |
+
return decodeURIComponent(escape(atob(text)));
|
| 310 |
+
case 'url':
|
| 311 |
+
return decodeURIComponent(text);
|
| 312 |
+
case 'html':
|
| 313 |
+
const doc = new DOMParser().parseFromString(text, 'text/html');
|
| 314 |
+
return doc.documentElement.textContent;
|
| 315 |
+
case 'hex':
|
| 316 |
+
return text.split(' ').map(h => String.fromCharCode(parseInt(h, 16))).join('');
|
| 317 |
+
case 'binary':
|
| 318 |
+
return text.split(' ').map(b => String.fromCharCode(parseInt(b, 2))).join('');
|
| 319 |
+
case 'rot13':
|
| 320 |
+
return text.replace(/[a-zA-Z]/g, function(c) {
|
| 321 |
+
return String.fromCharCode((c <= 'Z' ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
|
| 322 |
+
});
|
| 323 |
+
default:
|
| 324 |
+
return text;
|
| 325 |
+
}
|
| 326 |
+
} catch (e) {
|
| 327 |
+
return `Error: ${e.message}`;
|
| 328 |
+
}
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
// History functions
|
| 332 |
+
function addToHistory(method, input, output) {
|
| 333 |
+
const conversion = {
|
| 334 |
+
method: method.charAt(0).toUpperCase() + method.slice(1),
|
| 335 |
+
input: input.length > 30 ? input.substring(0, 30) + '...' : input,
|
| 336 |
+
output: output.length > 30 ? output.substring(0, 30) + '...' : output,
|
| 337 |
+
fullInput: input,
|
| 338 |
+
fullOutput: output,
|
| 339 |
+
time: new Date().toLocaleTimeString()
|
| 340 |
+
};
|
| 341 |
+
|
| 342 |
+
conversionHistory.unshift(conversion);
|
| 343 |
+
if (conversionHistory.length > 5) {
|
| 344 |
+
conversionHistory.pop();
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
localStorage.setItem('conversionHistory', JSON.stringify(conversionHistory));
|
| 348 |
+
updateHistoryTable();
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
function updateHistoryTable() {
|
| 352 |
+
if (conversionHistory.length === 0) {
|
| 353 |
+
historyTable.innerHTML = '';
|
| 354 |
+
emptyHistory.style.display = 'block';
|
| 355 |
+
return;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
emptyHistory.style.display = 'none';
|
| 359 |
+
historyTable.innerHTML = '';
|
| 360 |
+
|
| 361 |
+
conversionHistory.forEach(item => {
|
| 362 |
+
const row = document.createElement('tr');
|
| 363 |
+
row.className = 'hover:bg-gray-50 cursor-pointer';
|
| 364 |
+
row.innerHTML = `
|
| 365 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${item.method}</td>
|
| 366 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.input}</td>
|
| 367 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.output}</td>
|
| 368 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.time}</td>
|
| 369 |
+
`;
|
| 370 |
+
|
| 371 |
+
row.addEventListener('click', () => {
|
| 372 |
+
methodSelect.value = item.method.toLowerCase();
|
| 373 |
+
inputText.value = item.fullInput;
|
| 374 |
+
result.textContent = item.fullOutput;
|
| 375 |
+
|
| 376 |
+
// Set to decode if the output looks encoded
|
| 377 |
+
if (item.fullOutput !== decodeText(item.fullOutput, item.method.toLowerCase())) {
|
| 378 |
+
isEncoding = false;
|
| 379 |
+
decodeTab.classList.add('tab-active');
|
| 380 |
+
encodeTab.classList.remove('tab-active');
|
| 381 |
+
processBtn.innerHTML = '<i class="fas fa-cog mr-2"></i> Decode';
|
| 382 |
+
} else {
|
| 383 |
+
isEncoding = true;
|
| 384 |
+
encodeTab.classList.add('tab-active');
|
| 385 |
+
decodeTab.classList.remove('tab-active');
|
| 386 |
+
processBtn.innerHTML = '<i class="fas fa-cog mr-2"></i> Encode';
|
| 387 |
+
}
|
| 388 |
+
});
|
| 389 |
+
|
| 390 |
+
historyTable.appendChild(row);
|
| 391 |
+
});
|
| 392 |
+
}
|
| 393 |
+
});
|
| 394 |
+
</script>
|
| 395 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=DotSlashGabut/codecipher" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 396 |
+
</html>
|