Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
512 lines (480 loc) · 27.2 KB
/
Copy pathindex.html
File metadata and controls
512 lines (480 loc) · 27.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Cipher Museum — Interactive History of Encryption</title>
<meta name="description" content="Walk through 13 exhibit halls spanning 3,900+ years of cryptography, codebreaking, and secure communication. Explore 172 exhibits — 152 cipher and history exhibits, the Hall of Foundations mathematics annex, and the modern-protocol exhibits — interactive demos, and challenges.">
<link rel="icon" href="favicon.svg" type="image/svg+xml">
<link rel="manifest" href="manifest.webmanifest">
<meta property="og:title" content="The Cipher Museum — Interactive History of Encryption">
<meta property="og:description" content="Walk through 13 exhibit halls spanning 3,900+ years of cryptography, codebreaking, and secure communication. Explore 172 exhibits — 152 cipher and history exhibits, the Hall of Foundations mathematics annex, and the modern-protocol exhibits — interactive demos, and challenges.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://ciphermuseum.com/">
<meta property="og:image" content="https://ciphermuseum.com/images/og/og-default.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="The Cipher Museum — an interactive history of encryption">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="The Cipher Museum — Interactive History of Encryption">
<meta name="twitter:description" content="Walk through 13 exhibit halls spanning 3,900+ years of cryptography, codebreaking, and secure communication. Explore 172 exhibits — 152 cipher and history exhibits, the Hall of Foundations mathematics annex, and the modern-protocol exhibits — interactive demos, and challenges.">
<meta name="twitter:image" content="https://ciphermuseum.com/images/og/og-default.png">
<meta name="theme-color" content="#0a0a0f">
<link rel="canonical" href="https://ciphermuseum.com/">
<link rel="preload" href="fonts/cinzel-400-latin.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="fonts/cormorant-garamond-400-latin.woff2" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="css/museum.css">
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebSite","name":"The Cipher Museum","url":"https://ciphermuseum.com/","description":"Interactive history of encryption — 172 exhibits, 13 exhibit halls plus the Hall of Foundations mathematics annex, and 3,900+ years of cryptography, codebreaking, and secure communication.","publisher":{"@type":"Organization","name":"The Cipher Museum","url":"https://ciphermuseum.com/"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://ciphermuseum.com/search.html?q={search_term_string}"},"query-input":"required name=search_term_string"}}
</script>
</head>
<body>
<a class="skip-link" href="#main-content">Skip to main content</a>
<nav class="museum-nav" aria-label="Primary">
<div class="nav-inner">
<a href="index.html" class="nav-logo">
<svg class="nav-logo-icon" viewBox="0 0 32 32" fill="none">
<circle cx="16" cy="16" r="14" stroke="currentColor" stroke-width="1.5"/>
<circle cx="16" cy="16" r="8" stroke="currentColor" stroke-width="1"/>
<circle cx="16" cy="16" r="2" fill="currentColor"/>
<line x1="16" y1="2" x2="16" y2="6" stroke="currentColor" stroke-width="1.5"/>
<line x1="16" y1="26" x2="16" y2="30" stroke="currentColor" stroke-width="1.5"/>
<line x1="2" y1="16" x2="6" y2="16" stroke="currentColor" stroke-width="1.5"/>
<line x1="26" y1="16" x2="30" y2="16" stroke="currentColor" stroke-width="1.5"/>
</svg>
<span class="nav-logo-text">The Cipher Museum</span>
</a>
<ul class="nav-links">
<li><a href="museum-map.html">Explore</a></li>
<li><a href="timeline.html">Timeline</a></li>
<li><a href="learn.html">Learn</a></li>
<li><a href="cipher-corpus.html">Cipher Corpus</a></li>
<li><a href="cryptanalysis.html">Cryptanalysis</a></li>
<li><a href="challenges.html">Challenges</a></li>
<li><a href="lab/workbench.html">Lab</a></li>
<li><a href="search.html">Search</a></li>
</ul>
</div>
</nav>
<div class="ticker-strip" style="margin-top:.25rem">
<div class="ticker-wrap">
<div class="ticker-track">
<a href="ciphers/atbash.html" class="ticker-item"><span class="ticker-dot">◆</span>Atbash · ~600 BC</a>
<a href="ciphers/scytale.html" class="ticker-item"><span class="ticker-dot">◆</span>Scytale · ~500 BC</a>
<a href="ciphers/caesar.html" class="ticker-item"><span class="ticker-dot">◆</span>Caesar Cipher · 58 BC</a>
<a href="ciphers/aeneas-tacticus.html" class="ticker-item"><span class="ticker-dot">◆</span>Aeneas Tacticus · ~360 BC</a>
<a href="ciphers/alberti-disk.html" class="ticker-item"><span class="ticker-dot">◆</span>Alberti Disk · 1467</a>
<a href="ciphers/vigenere.html" class="ticker-item"><span class="ticker-dot">◆</span>Bellaso repeating-key method · 1553</a>
<a href="ciphers/argenti.html" class="ticker-item"><span class="ticker-dot">◆</span>Argenti Family Cipher · 1591</a>
<a href="ciphers/babington.html" class="ticker-item"><span class="ticker-dot">◆</span>Babington Plot · 1586</a>
<a href="ciphers/bacon.html" class="ticker-item"><span class="ticker-dot">◆</span>Bacon's Cipher · 1605</a>
<a href="ciphers/great-cipher.html" class="ticker-item"><span class="ticker-dot">◆</span>Great Cipher · 17th century</a>
<a href="ciphers/wallis-ciphers.html" class="ticker-item"><span class="ticker-dot">◆</span>Wallis Ciphers · 1643</a>
<a href="ciphers/copiale.html" class="ticker-item"><span class="ticker-dot">◆</span>Copiale · c. 1760–1780</a>
<a href="ciphers/jefferson-disk.html" class="ticker-item"><span class="ticker-dot">◆</span>Jefferson Disk · 1795</a>
<a href="ciphers/culper-ring.html" class="ticker-item"><span class="ticker-dot">◆</span>Culper Ring · 1779</a>
<a href="ciphers/playfair.html" class="ticker-item"><span class="ticker-dot">◆</span>Playfair · 1854</a>
<a href="ciphers/stager.html" class="ticker-item"><span class="ticker-dot">◆</span>Stager Cipher · 1861</a>
<a href="ciphers/beale.html" class="ticker-item"><span class="ticker-dot">◆</span>Beale Ciphers · 1885</a>
<a href="ciphers/chaocipher.html" class="ticker-item"><span class="ticker-dot">◆</span>Chaocipher · 1918</a>
<a href="ciphers/adfgvx.html" class="ticker-item"><span class="ticker-dot">◆</span>ADFGVX · 1918</a>
<a href="ciphers/zimmermann.html" class="ticker-item"><span class="ticker-dot">◆</span>Zimmermann Telegram · 1917</a>
<a href="ciphers/enigma.html" class="ticker-item"><span class="ticker-dot">◆</span>Enigma Machine · 1923</a>
<a href="ciphers/purple.html" class="ticker-item"><span class="ticker-dot">◆</span>Purple (Type 97) · 1939</a>
<a href="ciphers/lorenz.html" class="ticker-item"><span class="ticker-dot">◆</span>Lorenz Cipher · 1940</a>
<a href="ciphers/geheimschreiber.html" class="ticker-item"><span class="ticker-dot">◆</span>Geheimschreiber · 1940</a>
<a href="ciphers/m209.html" class="ticker-item"><span class="ticker-dot">◆</span>M-209 · production 1942</a>
<a href="ciphers/navajo-code-talkers.html" class="ticker-item"><span class="ticker-dot">◆</span>Navajo Code Talkers · 1942</a>
<a href="ciphers/fialka.html" class="ticker-item"><span class="ticker-dot">◆</span>Fialka · 1956</a>
<a href="ciphers/vic.html" class="ticker-item"><span class="ticker-dot">◆</span>VIC Cipher · 1953</a>
<a href="ciphers/tap-code.html" class="ticker-item"><span class="ticker-dot">◆</span>Tap Code · 1965</a>
<a href="ciphers/diana-cryptosystem.html" class="ticker-item"><span class="ticker-dot">◆</span>Diana Cryptosystem · 1960s</a>
<a href="ciphers/venona.html" class="ticker-item"><span class="ticker-dot">◆</span>VENONA · 1943–1980</a>
<a href="ciphers/zodiac.html" class="ticker-item"><span class="ticker-dot">◆</span>Zodiac Ciphers · 1969</a>
<a href="ciphers/kryptos.html" class="ticker-item"><span class="ticker-dot">◆</span>Kryptos · 1990</a>
<a href="ciphers/cicada-3301.html" class="ticker-item"><span class="ticker-dot">◆</span>Cicada 3301 · 2012</a>
<a href="ciphers/one-time-pad.html" class="ticker-item"><span class="ticker-dot">◆</span>One-Time Pad · Perfect Secrecy</a>
</div>
</div>
</div>
<main id="main-content" tabindex="-1">
<section class="entrance-hero">
<div class="hero-ring"></div>
<div class="hero-ring"></div>
<div class="hero-ring"></div>
<div class="hero-content fade-up">
<div class="hero-eyebrow">History: c. 1900 BC — Present Day</div>
<h1 class="hero-wordmark">Explore the History of Encryption</h1>
<p class="hero-sub">172 exhibits, 13 halls plus the Foundations Annex, and 3,900+ years of cryptography, codebreaking, and secure communication — all in one place.</p>
<div class="hero-stats">
<div class="hero-stat"><span class="hero-stat-n" data-count="cipherHistory">152</span><span class="hero-stat-l">Cipher & History Exhibits</span></div>
<div class="hero-stat"><span class="hero-stat-n">13</span><span class="hero-stat-l">Exhibit Halls</span></div>
<div class="hero-stat"><span class="hero-stat-n">3,900+</span><span class="hero-stat-l">Years of History</span></div>
<div class="hero-stat"><span class="hero-stat-n">OTP</span><span class="hero-stat-l">Explore Perfect Secrecy</span></div>
</div>
<div class="hero-cta-group">
<a href="ciphers/caesar.html" class="hero-cta hero-cta--start">Start with Caesar Cipher →</a>
<a href="#playground" class="hero-cta hero-cta--ghost">Try the Playground</a>
<a href="museum-map.html" class="hero-cta hero-cta--ghost">View Museum Map</a>
</div>
</div>
</section>
<!-- ═══ §2 — CHOOSE YOUR PATH ═══ -->
<section class="section path-section">
<div class="section-head">
<span class="section-eyebrow">Start Here</span>
<h2 class="section-title">Choose Your Path</h2>
</div>
<div class="path-cards">
<a href="timeline.html" class="path-card path-card--explore">
<div class="path-card-icon" aria-hidden="true"><svg class="icon" width="40" height="40"><use href="images/icons.svg#i-columns"/></svg></div>
<h3 class="path-card-title">Explore History</h3>
<p class="path-card-desc">Browse ciphers by era — from ancient Greece to the Cold War.</p>
<span class="path-card-cta">Enter the Timeline →</span>
</a>
<a href="learn.html" class="path-card path-card--learn">
<div class="path-card-icon" aria-hidden="true"><svg class="icon" width="40" height="40"><use href="images/icons.svg#i-book"/></svg></div>
<h3 class="path-card-title">Learn How Ciphers Work</h3>
<p class="path-card-desc">Substitution, transposition, and comparisons with modern encryption.</p>
<span class="path-card-cta">Start Learning →</span>
</a>
<a href="challenges.html" class="path-card path-card--challenge">
<div class="path-card-icon" aria-hidden="true"><svg class="icon" width="40" height="40"><use href="images/icons.svg#i-swords"/></svg></div>
<h3 class="path-card-title">Try a Challenge</h3>
<p class="path-card-desc">Crack real ciphers, from beginner to expert.</p>
<span class="path-card-cta">Take a Challenge →</span>
</a>
<a href="cipher-corpus.html" class="path-card path-card--corpus">
<div class="path-card-icon" aria-hidden="true"><svg class="icon" width="40" height="40"><use href="images/icons.svg#i-flask"/></svg></div>
<h3 class="path-card-title">Benchmark & Break</h3>
<p class="path-card-desc">Practice with known ciphertext challenges and benchmark classical cryptanalysis tools.</p>
<span class="path-card-cta">Explore Cipher Corpus →</span>
</a>
</div>
</section>
<!-- ═══ §3 — LIVE CIPHER PLAYGROUND ═══ -->
<section class="section section--dark" id="playground">
<div class="section-head">
<span class="section-eyebrow">Try It Now</span>
<h2 class="section-title">Live Cipher Playground</h2>
</div>
<div class="playground-wrap" style="max-width:720px;margin:0 auto;">
<div class="panel" style="border-color:var(--gold-b);background:var(--s2);">
<div class="panel-body" style="padding:1.5rem;">
<div style="display:flex;gap:1rem;margin-bottom:1.25rem;flex-wrap:wrap;">
<div style="flex:1;min-width:140px;">
<label for="pg-cipher" style="font-family:var(--fm);font-size:.6rem;letter-spacing:.15em;text-transform:uppercase;color:var(--tx3);display:block;margin-bottom:.4rem;">Cipher</label>
<select id="pg-cipher" style="width:100%;background:var(--s3);border:1px solid var(--s5);border-radius:var(--r);color:var(--tx);font-family:var(--fm);font-size:.82rem;padding:.55rem .75rem;" aria-label="Choose cipher">
<option value="caesar">Caesar (Shift 3)</option>
<option value="rot13">ROT-13</option>
<option value="atbash">Atbash</option>
<option value="vigenere">Vigenère</option>
<option value="beaufort">Beaufort</option>
<option value="affine">Affine (a=5, b=8)</option>
<option value="railfence">Rail Fence</option>
<option value="polybius">Polybius Square</option>
<option value="bacon">Bacon-style (25-letter variant)</option>
</select>
</div>
<div id="pg-key-wrap" style="flex:1;min-width:120px;display:none;">
<label for="pg-key" style="font-family:var(--fm);font-size:.6rem;letter-spacing:.15em;text-transform:uppercase;color:var(--tx3);display:block;margin-bottom:.4rem;">Key</label>
<input id="pg-key" type="text" value="MUSEUM" maxlength="20" spellcheck="false" autocomplete="off" style="width:100%;background:var(--s3);border:1px solid var(--s5);border-radius:var(--r);color:var(--gold);font-family:var(--fm);font-size:.82rem;padding:.55rem .75rem;" aria-label="Cipher key">
</div>
<div style="display:flex;align-items:end;">
<button id="pg-swap" style="font-family:var(--fd);font-size:.72rem;letter-spacing:.1em;text-transform:uppercase;padding:.6rem 1rem;border:1px solid var(--gold-b);border-radius:var(--r);background:var(--s3);color:var(--gold);cursor:pointer;" aria-label="Switch between encrypt and decrypt">↕ Decrypt</button>
</div>
</div>
<div style="margin-bottom:1rem;">
<label for="pg-input" style="font-family:var(--fm);font-size:.6rem;letter-spacing:.15em;text-transform:uppercase;color:var(--tx3);display:block;margin-bottom:.4rem;">Plaintext</label>
<textarea id="pg-input" rows="2" spellcheck="false" autocomplete="off" placeholder="Type anything…" style="width:100%;background:var(--s3);border:1px solid var(--s5);border-radius:var(--r);color:var(--tx);font-family:var(--fm);font-size:.88rem;padding:.75rem;resize:vertical;line-height:1.6;" aria-label="Text to encrypt or decrypt"></textarea>
</div>
<div>
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:.4rem;">
<span style="font-family:var(--fm);font-size:.6rem;letter-spacing:.15em;text-transform:uppercase;color:var(--tx3);">Output</span>
<button id="pg-copy" style="font-family:var(--fm);font-size:.55rem;letter-spacing:.1em;padding:.25rem .6rem;background:var(--s3);border:1px solid var(--s5);border-radius:var(--r);color:var(--tx3);cursor:pointer;">COPY</button>
</div>
<div id="pg-output" style="background:var(--s1);border:1px solid var(--gold-b);border-radius:var(--r);padding:.75rem;font-family:var(--fm);font-size:.88rem;color:var(--gold-lt);min-height:2.5rem;line-height:1.6;letter-spacing:.06em;word-break:break-all;white-space:pre-wrap;"></div>
</div>
<p style="font-size:.82rem;color:var(--tx3);margin-top:1rem;text-align:center;">Want more ciphers and frequency analysis? <a href="lab/workbench.html">Open the full Workbench →</a></p>
</div>
</div>
</div>
</section>
<!-- ═══ §4 — ERA HIGHLIGHTS ═══ -->
<section class="section reveal">
<div class="section-head">
<span class="section-eyebrow">3,900+ Years in Three Acts</span>
<h2 class="section-title">The Story of Encryption</h2>
</div>
<div class="timeline-preview">
<a href="halls/ancient.html" class="era-card">
<span class="era-card-dot" style="background:#C8845A;"></span>
<div class="era-card-body">
<h3 class="era-card-title">Act I · Ancient World to Paper Systems</h3>
<span class="era-card-date">c. 1900 BC – 1900</span>
<p class="era-card-desc">From unusual writing in Khnumhotep II’s tomb—not evidence of secret communication—to classical substitution, transposition and repeating-key systems.</p>
</div>
<span class="era-card-arrow">→</span>
</a>
<a href="halls/machines.html" class="era-card">
<span class="era-card-dot" style="background:#C85A5A;"></span>
<div class="era-card-body">
<h3 class="era-card-title">Act II · Machines & War</h3>
<span class="era-card-date">1900 – 1945</span>
<p class="era-card-desc">From WWI field systems to Enigma and Lorenz in WWII, ending with the first codebreaking computers.</p>
</div>
<span class="era-card-arrow">→</span>
</a>
<a href="halls/unbreakable.html" class="era-card">
<span class="era-card-dot" style="background:#5AC8A0;"></span>
<div class="era-card-body">
<h3 class="era-card-title">Act III · Mathematical Security</h3>
<span class="era-card-date">1945 – Present</span>
<p class="era-card-desc">From post-war information theory to modern cryptography: Shannon's 1949 proof and the rise of mathematical security.</p>
</div>
<span class="era-card-arrow">→</span>
</a>
<a href="hall-of-foundations/index.html" class="era-card">
<span class="era-card-dot" style="background:#2A6F6B;"></span>
<div class="era-card-body">
<h3 class="era-card-title">Annex · Hall of Foundations</h3>
<span class="era-card-date">The Mathematics Under It All</span>
<p class="era-card-desc">Exhibits §141–157: the number theory, hardness assumptions, and structures your keys stand on — from finite fields to lattices and pairings, each with a working interactive.</p>
</div>
<span class="era-card-arrow">→</span>
</a>
</div>
<div class="section-more">
<a href="timeline.html" class="view-all-link">View Full Timeline →</a>
</div>
</section>
<!-- ═══ §5 — MINI ABOUT ═══ -->
<section class="section section--dark" style="padding-top:2.5rem;padding-bottom:2.5rem">
<div class="content-narrow" style="text-align:center">
<p style="font-family:var(--fb);font-size:1.05rem;color:var(--tx2);line-height:1.8;max-width:640px;margin:0 auto">The Cipher Museum is part digital exhibit, part cipher playground, and part codebreaking classroom exploring 3,900+ years of encryption, cryptanalysis, and hidden history. No tracking. No backend. Just history.</p>
</div>
</section>
</main>
<footer></footer>
<script>
// Intersection observer for fade-up animations (graceful fallback for older browsers)
(function(){
var els = document.querySelectorAll('.fade-up');
if (typeof IntersectionObserver === 'undefined') {
els.forEach(function(el){ el.style.animationPlayState = 'running'; });
return;
}
var io = new IntersectionObserver(function(entries) {
entries.forEach(function(e) { if (e.isIntersecting) { e.target.style.animationPlayState='running'; io.unobserve(e.target); }});
}, {threshold:.1});
els.forEach(function(el) { el.style.animationPlayState='paused'; io.observe(el); });
})();
</script>
<!-- Playground engine (self-contained, no external deps) -->
<script>
'use strict';
(function(){
var A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var mod = function(a,m){ return((a%m)+m)%m; };
var engines = {
caesar: {
enc: function(t){ return t.split('').map(function(ch){
var c=ch.toUpperCase(); var i=A.indexOf(c);
if(i<0) return ch; var o=A[mod(i+3,26)];
return ch===c?o:o.toLowerCase();
}).join(''); },
dec: function(t){ return t.split('').map(function(ch){
var c=ch.toUpperCase(); var i=A.indexOf(c);
if(i<0) return ch; var o=A[mod(i-3,26)];
return ch===c?o:o.toLowerCase();
}).join(''); }
},
rot13: {
enc: function(t){ return t.split('').map(function(ch){
var c=ch.toUpperCase(); var i=A.indexOf(c);
if(i<0) return ch; var o=A[mod(i+13,26)];
return ch===c?o:o.toLowerCase();
}).join(''); },
dec: function(t){ return this.enc(t); }
},
atbash: {
enc: function(t){ return t.split('').map(function(ch){
var c=ch.toUpperCase(); var i=A.indexOf(c);
if(i<0) return ch; var o=A[25-i];
return ch===c?o:o.toLowerCase();
}).join(''); },
dec: function(t){ return this.enc(t); }
},
vigenere: {
enc: function(t,k){
k=(k||'MUSEUM').toUpperCase().replace(/[^A-Z]/g,'');
if(!k) k='MUSEUM'; var ki=0;
return t.split('').map(function(ch){
var c=ch.toUpperCase(); var i=A.indexOf(c);
if(i<0) return ch;
var o=A[mod(i+A.indexOf(k[ki%k.length]),26)]; ki++;
return ch===c?o:o.toLowerCase();
}).join('');
},
dec: function(t,k){
k=(k||'MUSEUM').toUpperCase().replace(/[^A-Z]/g,'');
if(!k) k='MUSEUM'; var ki=0;
return t.split('').map(function(ch){
var c=ch.toUpperCase(); var i=A.indexOf(c);
if(i<0) return ch;
var o=A[mod(i-A.indexOf(k[ki%k.length]),26)]; ki++;
return ch===c?o:o.toLowerCase();
}).join('');
}
},
beaufort: {
enc: function(t,k){
k=(k||'MUSEUM').toUpperCase().replace(/[^A-Z]/g,'');
if(!k) k='MUSEUM'; var ki=0;
return t.split('').map(function(ch){
var c=ch.toUpperCase(); var i=A.indexOf(c);
if(i<0) return ch;
var o=A[mod(A.indexOf(k[ki%k.length])-i,26)]; ki++;
return ch===c?o:o.toLowerCase();
}).join('');
},
dec: function(t,k){ return this.enc(t,k); }
},
affine: {
enc: function(t){
return t.split('').map(function(ch){
var c=ch.toUpperCase(); var i=A.indexOf(c);
if(i<0) return ch; var o=A[mod(5*i+8,26)];
return ch===c?o:o.toLowerCase();
}).join('');
},
dec: function(t){
return t.split('').map(function(ch){
var c=ch.toUpperCase(); var i=A.indexOf(c);
if(i<0) return ch; var o=A[mod(21*(i-8),26)];
return ch===c?o:o.toLowerCase();
}).join('');
}
},
railfence: {
enc: function(t){
var rails=['','',''];
var r=0,dir=1;
for(var i=0;i<t.length;i++){
rails[r]+=t[i];
if(r===0) dir=1; if(r===2) dir=-1;
r+=dir;
}
return rails.join('');
},
dec: function(t){
var n=t.length,lens=[0,0,0],r=0,dir=1;
for(var i=0;i<n;i++){ lens[r]++; if(r===0)dir=1;if(r===2)dir=-1;r+=dir; }
var rows=['','',''],pos=0;
for(var j=0;j<3;j++){ rows[j]=t.substr(pos,lens[j]); pos+=lens[j]; }
var idx=[0,0,0]; r=0;dir=1; var out='';
for(var i=0;i<n;i++){ out+=rows[r][idx[r]++]; if(r===0)dir=1;if(r===2)dir=-1;r+=dir; }
return out;
}
},
polybius: {
enc: function(t){
var grid='ABCDEFGHIKLMNOPQRSTUVWXYZ';
return t.split('').map(function(ch){
var c=ch.toUpperCase(); if(c==='J') c='I';
var idx=grid.indexOf(c);
if(idx<0) return ch;
return ''+(Math.floor(idx/5)+1)+(idx%5+1);
}).join(' ');
},
dec: function(t){
var grid='ABCDEFGHIKLMNOPQRSTUVWXYZ';
return t.replace(/([1-5])([1-5])/g,function(_,r,c){
var idx=(parseInt(r)-1)*5+(parseInt(c)-1);
return (idx>=0&&idx<25)?grid[idx]:'';
});
}
},
bacon: {
// 25-letter Bacon (I/J merged). 25 × 5 = 125 chars.
// A=AAAAA B=AAAAB C=AAABA D=AAABB E=AABAA F=AABAB G=AABBA H=AABBB
// I/J=ABAAA K=ABAAB L=ABABA M=ABABB N=ABBAA O=ABBAB P=ABBBA Q=ABBBB
// R=BAAAA S=BAAAB T=BAABA U=BAABB V=BABAA W=BABAB X=BABBA Y=BABBB Z=BBAAA
enc: function(t){
var codes='AAAAAAAAABAAABAAAABBAABAAAABABAABBAAABBBABAAAABAABABABAABABBABBAAABBABABBBAABBBBBAAAABAAABBAABABAABBBABAABABABBABBABABBBBBAAA';
return t.split('').map(function(ch){
var c=ch.toUpperCase(); if(c==='J') c='I'; var i=A.indexOf(c);
if(i<0) return ch; if(i>9) i--;
return codes.substr(i*5,5);
}).join(' ');
},
dec: function(t){
var codes='AAAAAAAAABAAABAAAABBAABAAAABABAABBAAABBBABAAAABAABABABAABABBABBAAABBABABBBAABBBBBAAAABAAABBAABABAABBBABAABABABBABBABABBBBBAAA';
var clean=t.replace(/[^AaBb]/g,'').toUpperCase();
var out='';
for(var i=0;i+5<=clean.length;i+=5){
var chunk=clean.substr(i,5);
for(var j=0;j<25;j++){ if(codes.substr(j*5,5)===chunk){ var c=j; if(c>=9) c++; out+=A[c]; break; }}
}
return out;
}
}
};
var selCipher = document.getElementById('pg-cipher');
var elInput = document.getElementById('pg-input');
var elOutput = document.getElementById('pg-output');
var elKey = document.getElementById('pg-key');
var elKeyWrap = document.getElementById('pg-key-wrap');
var btnSwap = document.getElementById('pg-swap');
var btnCopy = document.getElementById('pg-copy');
var encrypting = true;
function update(){
var name = selCipher.value;
var eng = engines[name];
var text = elInput.value;
var key = elKey.value;
elKeyWrap.style.display = (name==='vigenere'||name==='beaufort')?'':'none';
if(!text){ elOutput.textContent=''; return; }
elOutput.textContent = encrypting ? eng.enc(text,key) : eng.dec(text,key);
}
selCipher.addEventListener('change', update);
elInput.addEventListener('input', update);
elKey.addEventListener('input', update);
btnSwap.addEventListener('click', function(){
encrypting = !encrypting;
btnSwap.textContent = encrypting ? '↕ Decrypt' : '↕ Encrypt';
var lbl = elInput.previousElementSibling;
lbl.textContent = encrypting ? 'Plaintext' : 'Ciphertext';
update();
});
btnCopy.addEventListener('click', function(){
var text = elOutput.textContent;
if(text && navigator.clipboard){
navigator.clipboard.writeText(text);
btnCopy.textContent = 'COPIED';
setTimeout(function(){ btnCopy.textContent='COPY'; }, 1200);
}
});
// Seed with a demo message
elInput.value = 'The die is cast';
update();
})();
</script>
<script src="js/nav.js" defer></script>
<script src="js/lightbox.js"></script>
<script>
(function(){
var track=document.querySelector('.ticker-track');
if(!track)return;
var items=track.querySelectorAll('.ticker-item:not([data-ticker-clone])');
items.forEach(function(el){
var c=el.cloneNode(true);
c.setAttribute('data-ticker-clone','');
c.setAttribute('aria-hidden','true');
c.setAttribute('tabindex','-1');
track.appendChild(c);
});
})();
</script>
</body>
</html>