-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
270 lines (228 loc) · 8.35 KB
/
index.html
File metadata and controls
270 lines (228 loc) · 8.35 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Decodedly | Spy-Craft Edition</title>
<style>
/* --- Layout & Theme --- */
body {
font-family: 'Courier New', Courier, monospace;
background: #0d1117;
color: #c9d1d9;
padding: 40px 20px;
max-width: 800px;
margin: auto;
line-height: 1.5;
}
/* --- Header Styles --- */
h1 {
font-size: 2em;
margin-bottom: 0.2em;
color: #58a6ff;
}
h2 {
font-size: 1.1em;
color: #8b949e;
margin-top: 0.5em;
letter-spacing: 1px;
text-transform: uppercase;
}
/* --- Intro Box --- */
.intro {
background: #161b22;
padding: 15px 20px;
border-left: 4px solid #f85149; /* Red for 'Secret' feel */
margin-bottom: 25px;
font-size: 0.95em;
}
/* --- Input Areas --- */
textarea {
width: 100%;
height: 90px;
margin-bottom: 15px;
background: #0d1117;
color: #58a6ff;
border: 1px solid #30363d;
padding: 10px;
font-family: inherit;
font-size: 1em;
resize: vertical;
}
textarea:focus {
outline: none;
border-color: #58a6ff;
}
/* --- Buttons --- */
button {
background: #21262d;
color: #c9d1d9;
border: 1px solid #f0f6fc1a;
padding: 8px 16px;
font-size: 1em;
cursor: pointer;
margin: 5px 5px 15px 0;
border-radius: 4px;
font-family: inherit;
}
button:hover {
background: #30363d;
border-color: #8b949e;
}
.btn-primary {
background: #238636;
color: white;
}
.btn-primary:hover {
background: #2ea043;
}
/* --- Status & Output --- */
.status {
font-weight: bold;
margin-bottom: 15px;
color: #ffa657;
text-transform: uppercase;
font-size: 0.8em;
}
pre {
background: #161b22;
color: #c9d1d9;
padding: 10px;
border: 1px solid #30363d;
overflow-x: auto;
font-size: 0.85em;
}
.label {
margin-bottom: 5px;
font-weight: bold;
color: #79c0ff;
text-transform: uppercase;
font-size: 0.85em;
}
a {
color: #58a6ff;
}
</style>
</head>
<body>
<h1>Decodedly 🔍</h1>
<h2>Public Transmission → Hidden Intelligence</h2>
<div class="intro">
<strong>The "Newspaper Code" Protocol:</strong>
In classic espionage, a secret agent might find a hidden message within a mundane newspaper article by using a unique key.
<br><br>
<strong>To Read a Message:</strong> Paste the <em>Public Cover Text</em> (the article) and the <em>Secret Key</em> provided to you. Click <strong>Decode</strong> to reveal the hidden intel.
<br><br>
<strong>To Create a Message:</strong> Enter your <em>Public Cover Text</em> and the <em>Hidden Message</em> you want to bury inside it. Click <strong>Generate Key</strong>. You can then share the key or the URL with your contact to reveal the secret.
</div>
<div class="status" id="status">📡 System Ready. Awaiting input...</div>
<div class="label">📄 Public Cover Text (e.g. Newspaper Snippet):</div>
<textarea id="cipher" placeholder="Paste the public text here..."></textarea>
<div class="label">👁️ Hidden Message (The Secret Intel):</div>
<textarea id="plain" placeholder="Enter the secret message to hide or reveal..."></textarea>
<div class="label">🔑 Secret Key (One-Time Pad):</div>
<textarea id="key" placeholder="Paste key or generate one..."></textarea>
<div class="label">🔗 Secure Transmission Link:</div>
<div style="display: flex; gap: 10px; align-items: center;">
<pre id="shareableUrl" style="flex: 1; margin: 0;">(Generate key to create link)</pre>
<button onclick="copyShareableUrl()" id="copyBtn" style="padding: 6px 12px;">📋 Copy</button>
</div>
<button class="btn-primary" onclick="generateKey()">🔑 Generate Key</button>
<button onclick="decodeText()">🔓 Decode</button>
<button onclick="encodeText()">🔐 Encode (Custom)</button>
<script>
/* Logic remains consistent with your original script to ensure compatibility */
const CHARSET = [];
for (let i = 32; i <= 126; i++) CHARSET.push(String.fromCharCode(i));
const CHARSET_LEN = CHARSET.length;
const charToIndex = c => CHARSET.indexOf(c);
const indexToChar = i => CHARSET[i % CHARSET_LEN];
const sanitize = str => Array.from(str).filter(c => charToIndex(c) !== -1).join('');
const repeatKey = (key, length) =>
key.length === 0 ? '' : Array.from({ length }, (_, i) => key[i % key.length]).join('');
function generateKey() {
const cipher = sanitize(document.getElementById('cipher').value);
const plain = sanitize(document.getElementById('plain').value);
if (plain.length > cipher.length) {
document.getElementById('status').textContent = "❌ ERROR: Cover text must be longer than Hidden Message.";
return;
}
const cipherPart = cipher.slice(0, plain.length);
let key = '';
for (let i = 0; i < plain.length; i++) {
const cIndex = charToIndex(cipherPart[i]);
const pIndex = charToIndex(plain[i]);
if (cIndex === -1 || pIndex === -1) return;
const shift = (cIndex - pIndex + CHARSET_LEN) % CHARSET_LEN;
key += indexToChar(shift);
}
document.getElementById('key').value = key;
document.getElementById('status').textContent = "✅ KEY GENERATED. Transmission ready.";
const encodedKey = encodeURIComponent(btoa(key));
const baseUrl = `${window.location.origin}${window.location.pathname}`;
document.getElementById('shareableUrl').textContent = `${baseUrl}?vkey=${encodedKey}`;
}
function encodeText() {
const plain = sanitize(document.getElementById('plain').value);
const key = repeatKey(sanitize(document.getElementById('key').value), plain.length);
if (!plain || !key) {
document.getElementById('status').textContent = "⚠️ Missing hidden message or key.";
return;
}
let encrypted = '';
for (let i = 0; i < plain.length; i++) {
const pIndex = charToIndex(plain[i]);
const kIndex = charToIndex(key[i]);
encrypted += indexToChar((pIndex + kIndex) % CHARSET_LEN);
}
document.getElementById('cipher').value = encrypted;
document.getElementById('status').textContent = "✅ Cover text generated.";
}
function decodeText() {
const cipher = sanitize(document.getElementById('cipher').value);
const key = repeatKey(sanitize(document.getElementById('key').value), cipher.length);
if (!cipher || !key) {
document.getElementById('status').textContent = "⚠️ Missing cover text or key.";
return;
}
let decrypted = '';
for (let i = 0; i < cipher.length; i++) {
const cIndex = charToIndex(cipher[i]);
const kIndex = charToIndex(key[i]);
decrypted += indexToChar((cIndex - kIndex + CHARSET_LEN) % CHARSET_LEN);
}
document.getElementById('plain').value = decrypted;
document.getElementById('status').textContent = "✅ INTELLIGENCE REVEALED.";
}
function getQueryParam(param) {
const params = new URLSearchParams(window.location.search);
return params.get(param);
}
function copyShareableUrl() {
const text = document.getElementById('shareableUrl').textContent;
navigator.clipboard.writeText(text).then(() => {
const btn = document.getElementById('copyBtn');
const original = btn.textContent;
btn.textContent = '✔ Copied';
setTimeout(() => btn.textContent = original, 1500);
});
}
window.onload = () => {
const vkey = getQueryParam('vkey');
if (vkey !== null) {
let decoded;
try {
decoded = atob(decodeURIComponent(vkey));
} catch (e) {
decoded = '';
}
const cleanKey = sanitize(decoded);
document.getElementById('key').value = cleanKey;
const baseUrl = `${window.location.origin}${window.location.pathname}`;
const safeKey = encodeURIComponent(btoa(cleanKey));
document.getElementById('shareableUrl').textContent = `${baseUrl}?vkey=${safeKey}`;
document.getElementById('status').textContent = "🔑 Key loaded from secure link. Paste cover text to reveal.";
}
};
</script>
</body>
</html>