-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencrypt.html
More file actions
584 lines (510 loc) · 29.8 KB
/
Copy pathencrypt.html
File metadata and controls
584 lines (510 loc) · 29.8 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Walar Encrypt</title>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=DM+Mono:wght@300;400;500&display=swap" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="walar_icon.png">
<style>
:root {
--glass-bg: rgba(255,255,255,0.06);
--glass-border: rgba(255,255,255,0.12);
--glass-highlight: rgba(255,255,255,0.20);
--accent: #3ecfff;
--accent2: #a78bfa;
--accent3: #34d399;
--accent-warn: rgba(255,170,50,0.90);
--text-primary: rgba(255,255,255,0.95);
--text-secondary: rgba(255,255,255,0.55);
--text-muted: rgba(255,255,255,0.28);
--bg-deep: #040810;
--radius-xl: 32px;
--font-main: 'Space Grotesk', sans-serif;
--font-mono: 'DM Mono', monospace;
}
* { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }
body { font-family:var(--font-main); background:var(--bg-deep); color:var(--text-primary); min-height:100vh; overflow-x:hidden; }
/* ── BG ── */
.bg-canvas { position:fixed; inset:0; z-index:0; overflow:hidden; pointer-events:none; }
.bg-canvas::before {
content:''; position:absolute; inset:0;
background:
radial-gradient(ellipse 70% 50% at 15% 20%, rgba(62,207,255,0.09) 0%, transparent 55%),
radial-gradient(ellipse 50% 60% at 85% 75%, rgba(167,139,250,0.08) 0%, transparent 55%),
radial-gradient(ellipse 40% 35% at 55% 45%, rgba(52,211,153,0.04) 0%, transparent 60%);
}
.bg-grid {
position:absolute; inset:0;
background-image: linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
background-size:60px 60px;
}
.orb { position:absolute; border-radius:50%; filter:blur(90px); animation:drift 22s ease-in-out infinite; }
.orb-1 { width:460px;height:460px;background:radial-gradient(circle,rgba(62,207,255,0.11),transparent);top:-120px;left:-120px; }
.orb-2 { width:360px;height:360px;background:radial-gradient(circle,rgba(167,139,250,0.10),transparent);bottom:-80px;right:-80px;animation-delay:-8s; }
.orb-3 { width:260px;height:260px;background:radial-gradient(circle,rgba(52,211,153,0.07),transparent);top:40%;left:55%;animation-delay:-15s; }
@keyframes drift { 0%,100%{transform:translate(0,0) scale(1);} 33%{transform:translate(35px,-25px) scale(1.04);} 66%{transform:translate(-18px,35px) scale(0.96);} }
/* floating particles */
.particle { position:absolute; border-radius:50%; animation:float-up linear infinite; opacity:0; }
@keyframes float-up { 0%{transform:translateY(0) scale(1);opacity:0;} 10%{opacity:0.6;} 90%{opacity:0.2;} 100%{transform:translateY(-100vh) scale(0.3);opacity:0;} }
/* ── NAV ── */
nav { position:fixed;top:0;left:0;right:0;z-index:100;padding:0 40px;height:64px;display:flex;align-items:center;justify-content:space-between;background:rgba(4,8,16,0.75);backdrop-filter:blur(24px) saturate(180%);-webkit-backdrop-filter:blur(24px) saturate(180%);border-bottom:1px solid var(--glass-border); }
.nav-logo { display:flex;align-items:center;gap:10px;font-weight:600;font-size:15px;letter-spacing:0.04em;text-decoration:none;color:var(--text-primary); }
.nav-logo-icon { width:28px;height:28px;border-radius:8px;background:linear-gradient(135deg,var(--accent),var(--accent2));display:flex;align-items:center;justify-content:center;font-size:14px;font-family:var(--font-mono);font-weight:500;color:#000; }
.nav-label { font-family:var(--font-mono);font-size:11px;color:var(--accent);letter-spacing:0.15em;text-transform:uppercase;padding:3px 8px;border:1px solid rgba(62,207,255,0.3);border-radius:4px;background:rgba(62,207,255,0.05); }
.nav-back { font-family:var(--font-mono);font-size:11px;color:var(--text-secondary);letter-spacing:0.1em;text-decoration:none;padding:6px 14px;border:1px solid var(--glass-border);border-radius:20px;background:var(--glass-bg);transition:all 0.2s;display:flex;align-items:center;gap:6px; }
.nav-back:hover { color:var(--text-primary);background:rgba(255,255,255,0.10); }
/* ── PAGE WRAPPER ── */
.page { position:relative;z-index:1;padding:100px 40px 80px;max-width:860px;margin:0 auto; }
/* ── HERO ── */
.hero-section { text-align:center;margin-bottom:72px; }
.hero-eyebrow { font-family:var(--font-mono);font-size:11px;letter-spacing:0.25em;text-transform:uppercase;color:var(--accent);margin-bottom:20px;opacity:0;animation:fadeUp 0.8s ease forwards 0.1s;display:flex;align-items:center;justify-content:center;gap:10px; }
.hero-eyebrow::before { content:'';width:40px;height:1px;background:linear-gradient(90deg,transparent,var(--accent)); }
.hero-eyebrow::after { content:'';width:40px;height:1px;background:linear-gradient(90deg,var(--accent),transparent); }
.hero-lockicon { font-size:52px;margin-bottom:20px;opacity:0;animation:fadeUp 0.8s ease forwards 0.15s;display:block;filter:drop-shadow(0 0 20px rgba(62,207,255,0.4)); }
.hero-title { font-size:clamp(36px,6vw,68px);font-weight:700;line-height:1.05;letter-spacing:-0.03em;margin-bottom:16px;opacity:0;animation:fadeUp 0.9s ease forwards 0.25s; }
.hero-title span { background:linear-gradient(135deg,var(--accent) 0%,var(--accent2) 60%,var(--accent3) 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text; }
.hero-sub { font-size:16px;color:var(--text-secondary);font-weight:300;max-width:480px;line-height:1.65;margin:0 auto;opacity:0;animation:fadeUp 0.9s ease forwards 0.38s; }
@keyframes fadeUp { from{opacity:0;transform:translateY(20px);} to{opacity:1;transform:translateY(0);} }
/* ── CARD ── */
.card {
background:var(--glass-bg);
border:1px solid var(--glass-border);
border-radius:var(--radius-xl);
padding:48px 52px;
backdrop-filter:blur(40px) saturate(180%);
-webkit-backdrop-filter:blur(40px) saturate(180%);
position:relative; overflow:hidden;
box-shadow: 0 0 0 1px rgba(255,255,255,0.04) inset, 0 32px 100px rgba(0,0,0,0.55);
margin-bottom:28px;
opacity:0; animation:fadeUp 1s ease forwards;
}
.card::before { content:'';position:absolute;top:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent,var(--glass-highlight),transparent); }
.card-header { display:flex;align-items:center;gap:14px;margin-bottom:36px; }
.card-icon { width:44px;height:44px;border-radius:14px;display:flex;align-items:center;justify-content:center;font-size:20px;flex-shrink:0;position:relative; }
.card-icon::after { content:'';position:absolute;inset:0;border-radius:inherit;background:inherit;filter:blur(14px);opacity:0.45;transform:scale(1.3); }
.card-icon-encrypt { background:linear-gradient(135deg,rgba(62,207,255,0.22),rgba(62,207,255,0.06)); }
.card-icon-legacy { background:linear-gradient(135deg,rgba(255,170,50,0.22),rgba(255,170,50,0.06)); }
.card-title-wrap { flex:1; }
.card-title { font-size:20px;font-weight:700;letter-spacing:-0.02em;margin-bottom:4px; }
.card-title-encrypt { color:var(--accent); }
.card-title-legacy { color:var(--accent-warn); }
.card-subtitle { font-family:var(--font-mono);font-size:11px;color:var(--text-muted);letter-spacing:0.12em; }
/* ── FORM ELEMENTS ── */
label { font-family:var(--font-mono);font-size:11px;letter-spacing:0.18em;text-transform:uppercase;color:var(--text-muted);display:block;margin-bottom:8px; }
textarea, .output-box {
width:100%; border-radius:14px; padding:16px 18px;
background:rgba(0,0,0,0.35); border:1px solid var(--glass-border);
color:var(--text-primary); font-family:var(--font-mono);font-size:14px;line-height:1.6;
resize:vertical; outline:none;
transition:border-color 0.25s, box-shadow 0.25s;
}
textarea::placeholder { color:var(--text-muted); }
textarea:focus { border-color:rgba(62,207,255,0.4); box-shadow:0 0 0 3px rgba(62,207,255,0.07); }
.output-box { min-height:90px;word-break:break-all;color:var(--accent);cursor:pointer;position:relative;user-select:all; }
.output-box.legacy-out { color:var(--accent-warn); }
.output-box:empty::before { content:'— output will appear here —';color:var(--text-muted);font-style:normal; }
/* key row */
.key-row { display:flex;gap:12px;align-items:flex-end;margin:20px 0; }
.key-field-wrap { flex:1; }
.key-input {
width:100%;border-radius:12px;padding:13px 16px;
background:rgba(0,0,0,0.35);border:1px solid rgba(62,207,255,0.25);
color:var(--accent);font-family:var(--font-mono);font-size:13px;letter-spacing:0.08em;
outline:none;transition:all 0.25s;
}
.key-input:focus { border-color:rgba(62,207,255,0.55);box-shadow:0 0 0 3px rgba(62,207,255,0.07); }
.key-input::placeholder { color:var(--text-muted); }
/* buttons */
.btn-row { display:flex;gap:10px;flex-wrap:wrap;margin-top:20px; }
.btn {
display:inline-flex;align-items:center;gap:7px;padding:11px 22px;border-radius:50px;
font-size:13px;font-weight:600;letter-spacing:0.03em;cursor:pointer;
transition:all 0.22s;border:none;font-family:var(--font-main);
}
.btn-primary { background:linear-gradient(135deg,var(--accent),var(--accent2));color:#000; }
.btn-primary:hover { transform:scale(1.04);box-shadow:0 8px 28px rgba(62,207,255,0.32); }
.btn-ghost { background:var(--glass-bg);border:1px solid var(--glass-border);color:var(--text-secondary); }
.btn-ghost:hover { background:rgba(255,255,255,0.10);color:var(--text-primary);transform:scale(1.03); }
.btn-warn { background:linear-gradient(135deg,rgba(255,170,50,0.85),rgba(255,120,50,0.80));color:#000; }
.btn-warn:hover { transform:scale(1.04);box-shadow:0 8px 28px rgba(255,170,50,0.28); }
.btn-warn-ghost { background:var(--glass-bg);border:1px solid rgba(255,170,50,0.25);color:rgba(255,170,50,0.75); }
.btn-warn-ghost:hover { background:rgba(255,170,50,0.08);color:var(--accent-warn); }
/* feedback badge */
.copy-toast { position:fixed;bottom:32px;left:50%;transform:translateX(-50%) translateY(10px);background:rgba(52,211,153,0.15);border:1px solid rgba(52,211,153,0.35);color:var(--accent3);padding:10px 22px;border-radius:50px;font-family:var(--font-mono);font-size:12px;letter-spacing:0.1em;opacity:0;transition:all 0.3s;pointer-events:none;z-index:999; }
.copy-toast.show { opacity:1;transform:translateX(-50%) translateY(0); }
/* divider */
.section-divider { display:flex;align-items:center;gap:16px;margin:60px 0 48px;opacity:0;animation:fadeUp 1s ease forwards 0.9s; }
.section-divider::before, .section-divider::after { content:'';flex:1;height:1px;background:linear-gradient(90deg,transparent,var(--glass-border)); }
.section-divider::after { background:linear-gradient(90deg,var(--glass-border),transparent); }
.divider-label { font-family:var(--font-mono);font-size:10px;letter-spacing:0.2em;color:var(--text-muted);white-space:nowrap;text-transform:uppercase; }
/* legacy badge */
.legacy-badge { display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:50px;font-family:var(--font-mono);font-size:10px;letter-spacing:0.15em;border:1px solid rgba(255,170,50,0.3);background:rgba(255,170,50,0.06);color:rgba(255,170,50,0.7);margin-bottom:18px; }
/* mode tabs */
.mode-tabs { display:flex;gap:8px;margin-bottom:24px; }
.tab { padding:7px 18px;border-radius:50px;font-size:12px;font-family:var(--font-mono);letter-spacing:0.08em;cursor:pointer;border:1px solid var(--glass-border);background:transparent;color:var(--text-muted);transition:all 0.2s; }
.tab.active-enc { border-color:rgba(62,207,255,0.4);background:rgba(62,207,255,0.08);color:var(--accent); }
.tab.active-dec { border-color:rgba(167,139,250,0.4);background:rgba(167,139,250,0.08);color:var(--accent2); }
.tab:hover:not(.active-enc):not(.active-dec) { color:var(--text-secondary); }
/* key hint */
.key-hint { font-family:var(--font-mono);font-size:11px;color:var(--text-muted);margin-top:8px;display:flex;align-items:center;gap:6px; }
.key-hint svg { opacity:0.5; }
/* step labels */
.step-label { font-family:var(--font-mono);font-size:10px;letter-spacing:0.18em;color:var(--text-muted);text-transform:uppercase;margin-bottom:8px;display:flex;align-items:center;gap:6px; }
.step-num { width:18px;height:18px;border-radius:50%;border:1px solid var(--glass-border);display:inline-flex;align-items:center;justify-content:center;font-size:9px;flex-shrink:0; }
.mt16 { margin-top:16px; }
.mt24 { margin-top:24px; }
/* responsive */
@media (max-width:640px) {
.page { padding:90px 20px 60px; }
.card { padding:32px 24px; }
.key-row { flex-direction:column; }
nav { padding:0 20px; }
}
</style>
</head>
<body>
<div class="bg-canvas">
<div class="bg-grid"></div>
<div class="orb orb-1"></div>
<div class="orb orb-2"></div>
<div class="orb orb-3"></div>
<div id="particles"></div>
</div>
<nav>
<a class="nav-logo" href="main.html">
<div class="nav-logo-icon">W</div>
<span>Walar</span>
</a>
<span class="nav-label">Encrypt</span>
<a class="nav-back" href="main.html">← Back</a>
</nav>
<div class="page">
<!-- HERO -->
<div class="hero-section">
<div class="hero-eyebrow">Walar · Encryption Suite</div>
<span class="hero-lockicon">🔐</span>
<h1 class="hero-title">Speak Through <span>Code</span></h1>
<p class="hero-sub">Transform any message into unreadable cipher. Only those with the key can ever read it.</p>
</div>
<!-- ── PRIMARY ENCRYPTOR ── -->
<div class="card" style="animation-delay:0.5s">
<div class="card-header">
<div class="card-icon card-icon-encrypt">🔑</div>
<div class="card-title-wrap">
<div class="card-title card-title-encrypt">Walar Cipher</div>
<div class="card-subtitle">// primary · key-based · proprietary algorithm</div>
</div>
</div>
<!-- mode tabs -->
<div class="mode-tabs">
<button class="tab active-enc" id="tab-enc" onclick="setMode('encrypt')">⬆ Encrypt</button>
<button class="tab" id="tab-dec" onclick="setMode('decrypt')">⬇ Decrypt</button>
</div>
<!-- ENCRYPT MODE -->
<div id="enc-panel">
<div class="step-label"><span class="step-num">1</span> Your message</div>
<textarea id="enc-input" rows="5" placeholder="Type your secret message here..."></textarea>
<div class="btn-row">
<button class="btn btn-primary" onclick="doEncrypt()">🔒 Encrypt</button>
<button class="btn btn-ghost" onclick="clearEnc()">✕ Clear</button>
</div>
<div class="mt24">
<div class="step-label"><span class="step-num">2</span> Encrypted output — share this</div>
<div class="output-box" id="enc-output" onclick="copyText('enc-output')"></div>
</div>
<div class="mt16">
<div class="step-label"><span class="step-num">3</span> Your key — keep this private</div>
<div class="output-box" id="enc-key" style="color:var(--accent2);min-height:52px;" onclick="copyText('enc-key')"></div>
<div class="key-hint">
<svg width="12" height="12" viewBox="0 0 12 12" fill="none"><circle cx="6" cy="6" r="5" stroke="currentColor" stroke-width="1"/><path d="M6 5v3M6 3.5v.5" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>
Click any field to copy · Share the encrypted text, keep the key secret
</div>
</div>
</div>
<!-- DECRYPT MODE -->
<div id="dec-panel" style="display:none;">
<div class="step-label"><span class="step-num">1</span> Encrypted message</div>
<textarea id="dec-cipher-input" rows="4" placeholder="Paste encrypted text here..."></textarea>
<div class="mt16">
<div class="step-label"><span class="step-num">2</span> Decryption key</div>
<div class="key-row">
<div class="key-field-wrap">
<input class="key-input" id="dec-key-input" type="text" placeholder="Paste your key here...">
</div>
</div>
</div>
<div class="btn-row">
<button class="btn btn-primary" style="background:linear-gradient(135deg,var(--accent2),var(--accent));" onclick="doDecrypt()">🔓 Decrypt</button>
<button class="btn btn-ghost" onclick="clearDec()">✕ Clear</button>
</div>
<div class="mt24">
<div class="step-label"><span class="step-num">3</span> Decrypted message</div>
<div class="output-box" id="dec-output" style="color:var(--accent3);" onclick="copyText('dec-output')"></div>
</div>
</div>
</div>
<!-- ── DIVIDER ── -->
<div class="section-divider">
<span class="divider-label">Legacy Archive · Est. 2021</span>
</div>
<!-- ── LEGACY ENCRYPTOR ── -->
<div class="card" style="animation-delay:1s">
<div class="card-header">
<div class="card-icon card-icon-legacy">📜</div>
<div class="card-title-wrap">
<div class="card-title card-title-legacy">Legacy Encryptor</div>
<div class="card-subtitle">// primitive · no key · historical record</div>
</div>
</div>
<div class="legacy-badge">⚠ Kept as legacy — the first and most primitive Walar encryptor</div>
<p style="font-size:14px;color:var(--text-secondary);line-height:1.65;margin-bottom:28px;font-weight:300;">
This was the original system — a simple character substitution table hand-crafted by the founders in the early days of Walar. No key, no dynamic cipher, just a fixed map. Preserved here as a historical artifact of where it all began.
</p>
<div class="mode-tabs">
<button class="tab active-enc" id="ltab-enc" onclick="setLegacyMode('encrypt')">⬆ Encrypt</button>
<button class="tab" id="ltab-dec" onclick="setLegacyMode('decrypt')">⬇ Decrypt</button>
</div>
<div id="leg-enc-panel">
<label>Input</label>
<textarea id="leg-enc-input" rows="4" placeholder="Type message..."></textarea>
<div class="btn-row">
<button class="btn btn-warn" onclick="doLegacyEncrypt()">🔒 Encrypt (Legacy)</button>
<button class="btn btn-warn-ghost" onclick="clearLegacy('enc')">✕ Clear</button>
</div>
<div class="mt24">
<label>Encrypted Output</label>
<div class="output-box legacy-out" id="leg-enc-output" onclick="copyText('leg-enc-output')"></div>
</div>
</div>
<div id="leg-dec-panel" style="display:none;">
<label>Encrypted Input</label>
<textarea id="leg-dec-input" rows="4" placeholder="Paste legacy cipher..."></textarea>
<div class="btn-row">
<button class="btn btn-warn" onclick="doLegacyDecrypt()">🔓 Decrypt (Legacy)</button>
<button class="btn btn-warn-ghost" onclick="clearLegacy('dec')">✕ Clear</button>
</div>
<div class="mt24">
<label>Decrypted Output</label>
<div class="output-box" id="leg-dec-output" style="color:var(--accent3);" onclick="copyText('leg-dec-output')"></div>
</div>
</div>
</div>
</div><!-- /page -->
<div class="copy-toast" id="copyToast">Copied to clipboard</div>
<script>
if (localStorage.getItem('isLoggedIn') !== 'true') window.location.href = 'index.html'; //auth
// ════════════════════════════════════════════════════
// WALAR CIPHER — Custom key-based encryption
// Algorithm: multi-layer substitution + positional
// XOR-style scramble using a derived numeric key seed.
// Not a standard cipher — custom Walar protocol.
// ════════════════════════════════════════════════════
const WALAR_CHARSET =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#%^&*()-_=+[]{}|;:,.<>?/~`\'"\\';
const CS_LEN = WALAR_CHARSET.length;
// derive a numeric seed array from a key string
function deriveSeeds(keyStr) {
const seeds = [];
for (let i = 0; i < keyStr.length; i++) {
seeds.push(keyStr.charCodeAt(i));
}
return seeds;
}
// generate a random alphanumeric key string
function genKey(len = 18) {
const pool = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789';
let k = '';
for (let i = 0; i < len; i++) k += pool[Math.floor(Math.random() * pool.length)];
// format as groups of 6
return k.match(/.{1,6}/g).join('-');
}
// encode a single char using position + seed
function encodeChar(char, pos, seeds) {
const ci = WALAR_CHARSET.indexOf(char);
if (ci === -1) return char; // pass-through for spaces / newlines
const seed = seeds[pos % seeds.length];
const shift = (seed + pos * 7 + Math.floor(pos / seeds.length) * 3) % CS_LEN;
return WALAR_CHARSET[(ci + shift + CS_LEN) % CS_LEN];
}
function decodeChar(char, pos, seeds) {
const ci = WALAR_CHARSET.indexOf(char);
if (ci === -1) return char;
const seed = seeds[pos % seeds.length];
const shift = (seed + pos * 7 + Math.floor(pos / seeds.length) * 3) % CS_LEN;
return WALAR_CHARSET[(ci - shift + CS_LEN) % CS_LEN];
}
// scramble pass: reverse blocks of size blockSize
function blockScramble(text, blockSize) {
const chars = text.split('');
for (let i = 0; i < chars.length; i += blockSize * 2) {
const slice = chars.splice(i, blockSize);
chars.splice(i, 0, ...slice.reverse());
}
return chars.join('');
}
function blockUnscramble(text, blockSize) {
// same operation — reversing a reversed block restores it
return blockScramble(text, blockSize);
}
function walarEncrypt(plaintext, keyStr) {
const seeds = deriveSeeds(keyStr.replace(/-/g, ''));
const blockSize = (seeds[0] % 4) + 3; // 3–6
// pass 1: char substitution
let out = '';
let ci = 0;
for (let i = 0; i < plaintext.length; i++) {
const c = plaintext[i];
if (c === ' ' || c === '\n' || c === '\r') { out += c; }
else { out += encodeChar(c, ci, seeds); ci++; }
}
// pass 2: block scramble (only on non-whitespace segments)
const segments = out.split(/(\s+)/);
const scrambled = segments.map((seg, idx) => {
if (/^\s+$/.test(seg)) return seg;
return blockScramble(seg, blockSize);
});
return scrambled.join('');
}
function walarDecrypt(cipher, keyStr) {
const seeds = deriveSeeds(keyStr.replace(/-/g, ''));
const blockSize = (seeds[0] % 4) + 3;
// undo pass 2
const segments = cipher.split(/(\s+)/);
const unscrambled = segments.map(seg => {
if (/^\s+$/.test(seg)) return seg;
return blockUnscramble(seg, blockSize);
});
const joined = unscrambled.join('');
// undo pass 1
let out = '';
let ci = 0;
for (let i = 0; i < joined.length; i++) {
const c = joined[i];
if (c === ' ' || c === '\n' || c === '\r') { out += c; }
else { out += decodeChar(c, ci, seeds); ci++; }
}
return out;
}
// ════════════════════════════════════════════════════
// LEGACY CIPHER — original Walar substitution table
// ════════════════════════════════════════════════════
function getEncryptedChar(char) {
switch(char){case 'a':return 'm';case 'b':return '4';case 'c':return '$';case 'd':return 'j';case 'e':return '5';case 'f':return 'e';case 'g':return 'k';case 'h':return 'h';case 'i':return 't';case 'j':return 'y';case 'k':return 'l';case 'l':return '6';case 'm':return 'i';case 'n':return '9';case 'o':return 'b';case 'p':return '1';case 'q':return 'r';case 'r':return 'w';case 's':return '2';case 't':return 'o';case 'u':return 'd';case 'v':return '8';case 'w':return 'g';case 'x':return 'a';case 'y':return 'f';case 'z':return '3';case ',':return '3';case ' ':return '0';case '1':return '!';case '2':return '@';case '3':return '#';case '4':return '$';case '5':return '%';case '6':return '^';case '7':return '&';case '8':return '*';case '9':return '(';case '0':return ')';default:return char;}
}
function getDecryptedChar(char) {
switch(char){case 'm':return 'a';case '4':return 'b';case '$':return 'c';case 'j':return 'd';case '5':return 'e';case 'e':return 'f';case 'k':return 'g';case 'h':return 'h';case 't':return 'i';case 'y':return 'j';case 'l':return 'k';case '6':return 'l';case 'i':return 'm';case '9':return 'n';case 'b':return 'o';case '1':return 'p';case 'r':return 'q';case 'w':return 'r';case '2':return 's';case 'o':return 't';case 'd':return 'u';case '8':return 'v';case 'g':return 'w';case 'a':return 'x';case 'f':return 'y';case '3':return 'z';case ',':return ',';case '0':return ' ';case '!':return '1';case '@':return '2';case '#':return '3';case '$':return '4';case '%':return '5';case '^':return '6';case '&':return '7';case '*':return '8';case '(':return '9';case ')':return '0';default:return char;}
}
// ════════════════════════════════════════════════════
// UI LOGIC
// ════════════════════════════════════════════════════
let currentMode = 'encrypt';
let currentLegacyMode = 'encrypt';
function setMode(m) {
currentMode = m;
document.getElementById('enc-panel').style.display = m === 'encrypt' ? '' : 'none';
document.getElementById('dec-panel').style.display = m === 'decrypt' ? '' : 'none';
document.getElementById('tab-enc').className = 'tab' + (m === 'encrypt' ? ' active-enc' : '');
document.getElementById('tab-dec').className = 'tab' + (m === 'decrypt' ? ' active-dec' : '');
}
function setLegacyMode(m) {
currentLegacyMode = m;
document.getElementById('leg-enc-panel').style.display = m === 'encrypt' ? '' : 'none';
document.getElementById('leg-dec-panel').style.display = m === 'decrypt' ? '' : 'none';
document.getElementById('ltab-enc').className = 'tab' + (m === 'encrypt' ? ' active-enc' : '');
document.getElementById('ltab-dec').className = 'tab' + (m === 'decrypt' ? ' active-dec' : '');
}
function setOutput(id, text) {
const el = document.getElementById(id);
el.textContent = text;
}
function doEncrypt() {
const txt = document.getElementById('enc-input').value.trim();
if (!txt) return flash('No message entered');
const key = genKey();
const cipher = walarEncrypt(txt, key);
setOutput('enc-output', cipher);
setOutput('enc-key', key);
}
function clearEnc() {
document.getElementById('enc-input').value = '';
setOutput('enc-output', '');
setOutput('enc-key', '');
}
function doDecrypt() {
const cipher = document.getElementById('dec-cipher-input').value.trim();
const key = document.getElementById('dec-key-input').value.trim();
if (!cipher) return flash('No cipher text entered');
if (!key) return flash('No key entered');
try {
const plain = walarDecrypt(cipher, key);
setOutput('dec-output', plain);
} catch(e) {
setOutput('dec-output', '[ decryption failed — check your key ]');
}
}
function clearDec() {
document.getElementById('dec-cipher-input').value = '';
document.getElementById('dec-key-input').value = '';
setOutput('dec-output', '');
}
function doLegacyEncrypt() {
const txt = document.getElementById('leg-enc-input').value;
if (!txt) return flash('No message entered');
const out = txt.toLowerCase().split('').map(getEncryptedChar).join('');
setOutput('leg-enc-output', out);
}
function doLegacyDecrypt() {
const txt = document.getElementById('leg-dec-input').value;
if (!txt) return flash('No cipher entered');
const out = txt.split('').map(getDecryptedChar).join('');
setOutput('leg-dec-output', out);
}
function clearLegacy(mode) {
if (mode === 'enc') { document.getElementById('leg-enc-input').value = ''; setOutput('leg-enc-output',''); }
else { document.getElementById('leg-dec-input').value = ''; setOutput('leg-dec-output',''); }
}
function copyText(id) {
const el = document.getElementById(id);
const text = el.textContent;
if (!text || text.startsWith('—')) return;
navigator.clipboard.writeText(text).then(() => flash('Copied to clipboard ✓')).catch(() => {
const sel = window.getSelection();
const range = document.createRange();
range.selectNodeContents(el);
sel.removeAllRanges();
sel.addRange(range);
flash('Select + copy manually');
});
}
let toastTimer = null;
function flash(msg) {
const t = document.getElementById('copyToast');
t.textContent = msg;
t.classList.add('show');
clearTimeout(toastTimer);
toastTimer = setTimeout(() => t.classList.remove('show'), 2200);
}
// ── particles ──
(function spawnParticles() {
const container = document.getElementById('particles');
const colors = ['rgba(62,207,255,0.5)','rgba(167,139,250,0.4)','rgba(52,211,153,0.35)'];
for (let i = 0; i < 18; i++) {
const p = document.createElement('div');
p.className = 'particle';
const size = Math.random() * 3 + 1;
p.style.cssText = `
width:${size}px;height:${size}px;
left:${Math.random()*100}%;
bottom:${-10 - Math.random()*10}%;
background:${colors[i%3]};
animation-duration:${12+Math.random()*18}s;
animation-delay:${Math.random()*20}s;
`;
container.appendChild(p);
}
})();
</script>
</body>
</html>