Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1022 lines (909 loc) · 36.8 KB
/
Copy pathindex.html
File metadata and controls
1022 lines (909 loc) · 36.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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Caesar Cipher Decoder & Encoder | Free ROT13 & Brute-Force Tool</title>
<meta name="description" content="Free online Caesar cipher decoder and encoder. Encrypt or decrypt with any shift, apply ROT13, and brute-force all 25 shifts to crack unknown messages instantly. 100% in your browser." />
<meta name="keywords" content="caesar cipher, caesar cipher decoder, caesar cipher encoder, shift cipher, rot13, rot13 decoder, caesar cipher solver, brute force caesar, cryptography, cipher tool" />
<meta name="author" content="Sylvester Das" />
<meta name="robots" content="index, follow, max-image-preview:large" />
<link rel="canonical" href="https://gykh.sylvesterdas.com/caesar-cipher/" />
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicon-32.png" />
<link rel="icon" type="image/png" sizes="192x192" href="assets/logo-192.png" />
<link rel="apple-touch-icon" href="assets/apple-touch-icon.png" />
<link rel="manifest" href="site.webmanifest" />
<meta name="theme-color" content="#0d1117" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Caesar Cipher Playground" />
<meta property="og:title" content="Caesar Cipher Decoder & Encoder: Free Online Tool" />
<meta property="og:description" content="Encrypt, decrypt, ROT13 and brute-force crack Caesar ciphers in your browser. Can you crack my secret message?" />
<meta property="og:url" content="https://gykh.sylvesterdas.com/caesar-cipher/" />
<meta property="og:image" content="https://gykh.sylvesterdas.com/caesar-cipher/assets/og-image.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="593" />
<meta property="og:image:alt" content="caesar-cipher: Encrypt, Decrypt, ROT13, Crack" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="https://gykh.sylvesterdas.com/caesar-cipher/assets/og-image.jpg" />
<meta name="twitter:title" content="Caesar Cipher Decoder & Encoder: Free Online Tool" />
<meta name="twitter:description" content="Encrypt, decrypt, ROT13 and brute-force crack Caesar ciphers in your browser. Can you crack my secret message?" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://gykh.sylvesterdas.com/" },
{ "@type": "ListItem", "position": 2, "name": "Caesar Cipher", "item": "https://gykh.sylvesterdas.com/caesar-cipher/" }
]
},
{
"@type": "WebApplication",
"@id": "https://gykh.sylvesterdas.com/caesar-cipher/#app",
"name": "Caesar Cipher Decoder & Encoder",
"url": "https://gykh.sylvesterdas.com/caesar-cipher/",
"image": "https://gykh.sylvesterdas.com/caesar-cipher/assets/og-image.jpg",
"applicationCategory": "UtilitiesApplication",
"operatingSystem": "Any (web browser)",
"browserRequirements": "Requires JavaScript",
"isAccessibleForFree": true,
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" },
"featureList": ["Caesar cipher encoder", "Caesar cipher decoder", "ROT13", "Brute-force all 25 shifts", "Shareable cipher challenges"],
"author": { "@id": "https://gykh.sylvesterdas.com/caesar-cipher/#author" },
"publisher": { "@id": "https://www.minifyn.com/#org" }
},
{
"@type": "SoftwareSourceCode",
"name": "@gykh/caesar-cipher",
"description": "Zero-dependency Caesar cipher library for Node.js with Strings, Buffers, Streams, ROT13 and brute-force cracking.",
"codeRepository": "https://github.com/get-your-knowledge-here/caesar-cipher",
"programmingLanguage": ["JavaScript", "TypeScript"],
"runtimePlatform": "Node.js",
"license": "https://opensource.org/licenses/MIT",
"author": { "@id": "https://gykh.sylvesterdas.com/caesar-cipher/#author" }
},
{
"@type": "Person",
"@id": "https://gykh.sylvesterdas.com/caesar-cipher/#author",
"name": "Sylvester Das",
"url": "https://www.sylvesterdas.com",
"worksFor": { "@id": "https://www.minifyn.com/#org" }
},
{
"@type": "Organization",
"@id": "https://www.minifyn.com/#org",
"name": "MiniFyn",
"url": "https://www.minifyn.com",
"slogan": "The simplest way to shorten, share, and track your links."
},
{
"@type": "FAQPage",
"mainEntity": [
{ "@type": "Question", "name": "What is a Caesar cipher?", "acceptedAnswer": { "@type": "Answer", "text": "A Caesar cipher is a substitution cipher that replaces each letter with the letter a fixed number of positions further along the alphabet. With a shift of 3, A becomes D and HELLO becomes KHOOR. It is named after Julius Caesar, who used it for private letters." } },
{ "@type": "Question", "name": "How do I decode a Caesar cipher without the key?", "acceptedAnswer": { "@type": "Answer", "text": "There are only 25 possible shifts, so you can try them all. Paste the message into this tool and the Cryptanalysis Cracker lists every shift at once; the readable line is the answer." } },
{ "@type": "Question", "name": "What is ROT13?", "acceptedAnswer": { "@type": "Answer", "text": "ROT13 is a Caesar cipher with a shift of 13. Because the alphabet has 26 letters, applying ROT13 twice returns the original text, so the same operation both encodes and decodes." } },
{ "@type": "Question", "name": "Is the Caesar cipher secure?", "acceptedAnswer": { "@type": "Answer", "text": "No. It can be broken in seconds by trying all 25 shifts. Use it for puzzles, games, teaching and light obfuscation, never for protecting real secrets." } },
{ "@type": "Question", "name": "Is my text sent to a server?", "acceptedAnswer": { "@type": "Answer", "text": "No. All encryption, decryption and cracking runs locally in your browser." } },
{ "@type": "Question", "name": "Can I use this Caesar cipher in my own code?", "acceptedAnswer": { "@type": "Answer", "text": "Yes. Install the free, MIT-licensed npm package @gykh/caesar-cipher. It supports strings, buffers and streams, plus ROT13 and brute-force cracking, with TypeScript types." } }
]
}
]
}
</script>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<style>
:root {
--bg: #0d1117;
--surface: #161b22;
--surface-elevated: #21262d;
--border: #30363d;
--border-focus: #58a6ff;
--text: #f0f6fc;
--text-muted: #8b949e;
--accent: #58a6ff;
--accent-hover: #79c0ff;
--accent-subtle: rgba(56, 139, 253, 0.15);
--success: #3fb950;
--font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
--font-mono: 'JetBrains Mono', monospace;
--radius-sm: 6px;
--radius-md: 10px;
--radius-lg: 14px;
--transition: all 0.18s ease;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: var(--bg);
color: var(--text);
font-family: var(--font-sans);
min-height: 100vh;
display: flex;
flex-direction: column;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
header {
border-bottom: 1px solid var(--border);
background: var(--surface);
padding: 1rem 1.5rem;
}
.breadcrumbs {
max-width: 1080px;
width: 100%;
margin: 1rem auto 0;
padding: 0 1.5rem;
font-size: 0.85rem;
color: var(--text-muted);
}
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; }
.breadcrumbs li + li::before { content: "›"; margin-right: 0.4rem; color: var(--text-muted); }
.breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs [aria-current] { color: var(--text); }
.header-inner {
max-width: 1080px;
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 1rem;
}
.logo-group {
display: flex;
align-items: center;
gap: 0.75rem;
}
.logo-icon {
width: 40px;
height: 40px;
display: block;
}
.logo-title {
font-size: 1.1rem;
font-weight: 700;
letter-spacing: -0.01em;
}
.logo-subtitle {
font-size: 0.8rem;
color: var(--text-muted);
}
.nav-links {
display: flex;
gap: 1rem;
align-items: center;
}
.nav-link {
color: var(--text-muted);
text-decoration: none;
font-size: 0.875rem;
font-weight: 500;
transition: var(--transition);
display: inline-flex;
align-items: center;
gap: 0.35rem;
}
.nav-link:hover {
color: var(--text);
}
main {
flex: 1;
max-width: 1080px;
width: 100%;
margin: 2rem auto;
padding: 0 1.5rem;
display: flex;
flex-direction: column;
gap: 2rem;
}
.playground-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 1.5rem;
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.controls-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1.25rem;
align-items: center;
background: var(--surface-elevated);
padding: 1.25rem;
border-radius: var(--radius-md);
border: 1px solid var(--border);
}
.control-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.control-label {
font-size: 0.85rem;
font-weight: 600;
color: var(--text-muted);
display: flex;
justify-content: space-between;
align-items: center;
}
.shift-badge {
background: var(--accent-subtle);
color: var(--accent);
padding: 0.15rem 0.5rem;
border-radius: var(--radius-sm);
font-family: var(--font-mono);
font-size: 0.85rem;
font-weight: 700;
}
.slider-wrapper {
display: flex;
align-items: center;
gap: 0.75rem;
}
input[type="range"] {
flex: 1;
accent-color: var(--accent);
cursor: pointer;
}
.btn-group {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.btn {
background: var(--surface);
border: 1px solid var(--border);
color: var(--text);
padding: 0.5rem 0.85rem;
border-radius: var(--radius-sm);
font-size: 0.85rem;
font-weight: 600;
cursor: pointer;
font-family: inherit;
transition: var(--transition);
}
.btn:hover {
background: var(--surface-elevated);
border-color: var(--border-focus);
}
.btn.active {
background: var(--accent);
border-color: var(--accent);
color: #fff;
}
.alphabet-mapping {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 0.75rem 1rem;
font-family: var(--font-mono);
font-size: 0.8rem;
overflow-x: auto;
white-space: nowrap;
color: var(--text-muted);
}
.alphabet-mapping span.plain {
color: var(--text);
font-weight: 600;
}
.alphabet-mapping span.cipher {
color: var(--accent);
font-weight: 600;
}
.editors-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1.25rem;
}
@media (max-width: 768px) {
.editors-grid {
grid-template-columns: 1fr;
}
}
.editor-pane {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.pane-header {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.85rem;
font-weight: 600;
color: var(--text-muted);
}
textarea {
background: var(--bg);
border: 1px solid var(--border);
color: var(--text);
font-family: var(--font-mono);
font-size: 0.925rem;
border-radius: var(--radius-md);
padding: 1rem;
min-height: 160px;
resize: vertical;
outline: none;
transition: var(--transition);
line-height: 1.6;
}
textarea:focus {
border-color: var(--border-focus);
box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}
.copy-btn {
background: transparent;
border: none;
color: var(--accent);
font-size: 0.8rem;
font-weight: 600;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 0.25rem;
}
.copy-btn:hover {
text-decoration: underline;
}
.cracker-section {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 1.5rem;
display: flex;
flex-direction: column;
gap: 1rem;
}
.section-title {
font-size: 1.15rem;
font-weight: 700;
letter-spacing: -0.01em;
}
.section-desc {
font-size: 0.875rem;
color: var(--text-muted);
}
.cracker-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 0.75rem;
max-height: 420px;
overflow-y: auto;
padding-right: 0.25rem;
}
.crack-card {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 0.75rem 1rem;
display: flex;
flex-direction: column;
gap: 0.35rem;
cursor: pointer;
transition: var(--transition);
}
.crack-card:hover {
border-color: var(--border-focus);
transform: translateY(-1px);
}
.crack-card-header {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.75rem;
color: var(--text-muted);
font-family: var(--font-mono);
}
.crack-card-text {
font-family: var(--font-mono);
font-size: 0.85rem;
color: var(--text);
word-break: break-all;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.toast {
position: fixed;
bottom: 2rem;
right: 2rem;
background: var(--success);
color: #fff;
padding: 0.6rem 1.2rem;
border-radius: var(--radius-md);
font-size: 0.875rem;
font-weight: 600;
opacity: 0;
pointer-events: none;
transform: translateY(10px);
transition: var(--transition);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.toast.show {
opacity: 1;
transform: translateY(0);
}
footer {
border-top: 1px solid var(--border);
background: var(--surface);
padding: 1.5rem;
text-align: center;
font-size: 0.85rem;
color: var(--text-muted);
margin-top: auto;
}
footer a {
color: var(--accent);
text-decoration: none;
}
footer p + p {
margin-top: 0.4rem;
}
.intro {
font-size: 0.95rem;
color: var(--text-muted);
max-width: 760px;
}
.intro strong {
color: var(--text);
}
.share-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.75rem;
padding-top: 1rem;
border-top: 1px solid var(--border);
font-size: 0.85rem;
color: var(--text-muted);
}
.share-row a {
color: var(--accent);
font-weight: 600;
text-decoration: none;
}
.share-row a:hover {
text-decoration: underline;
}
.btn.primary {
background: var(--accent);
border-color: var(--accent);
color: #0d1117;
}
.btn.primary:hover {
background: var(--accent-hover);
}
.promo {
background: linear-gradient(135deg, rgba(124, 58, 237, 0.14), rgba(88, 166, 255, 0.08));
border: 1px solid rgba(124, 58, 237, 0.45);
border-radius: var(--radius-lg);
padding: 1.5rem;
display: flex;
flex-direction: column;
gap: 1rem;
}
.promo-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 0.75rem;
}
.promo-card {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 1rem;
text-decoration: none;
color: var(--text);
display: flex;
flex-direction: column;
gap: 0.35rem;
transition: var(--transition);
}
.promo-card:hover {
border-color: #a78bfa;
transform: translateY(-1px);
}
.promo-card strong {
font-size: 0.95rem;
}
.promo-card span {
font-size: 0.83rem;
color: var(--text-muted);
}
.promo-card em {
font-style: normal;
font-size: 0.8rem;
font-weight: 600;
color: #a78bfa;
margin-top: auto;
}
.content {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 1.5rem;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 1.5rem 2rem;
font-size: 0.9rem;
color: var(--text-muted);
}
.content h2 {
font-size: 1.05rem;
color: var(--text);
margin-bottom: 0.5rem;
}
.content p + p,
.content ol {
margin-top: 0.5rem;
}
.content ol {
padding-left: 1.2rem;
}
.content code,
.content pre {
font-family: var(--font-mono);
font-size: 0.82rem;
color: var(--text);
}
.content pre {
background: var(--bg);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 0.75rem;
margin-top: 0.5rem;
overflow-x: auto;
}
.content a {
color: var(--accent);
}
.faq {
grid-column: 1 / -1;
}
.faq details {
border-top: 1px solid var(--border);
padding: 0.75rem 0;
}
.faq summary {
cursor: pointer;
color: var(--text);
font-weight: 600;
}
.faq details p {
margin-top: 0.5rem;
}
</style>
</head>
<body>
<header>
<div class="header-inner">
<div class="logo-group">
<img class="logo-icon" src="assets/logo-96.png" width="40" height="40" alt="Get Your Knowledge Here logo" />
<div>
<h1 class="logo-title">Caesar Cipher Decoder & Encoder</h1>
<p class="logo-subtitle">Free & private · Powered by @gykh/caesar-cipher</p>
</div>
</div>
<nav class="nav-links">
<a class="nav-link" href="https://github.com/get-your-knowledge-here/caesar-cipher" target="_blank" rel="noopener">GitHub ↗</a>
<a class="nav-link" href="https://www.npmjs.com/package/@gykh/caesar-cipher" target="_blank" rel="noopener">npm ↗</a>
<a class="nav-link" href="https://www.minifyn.com/?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=nav" target="_blank" rel="noopener">MiniFyn ↗</a>
</nav>
</div>
</header>
<nav class="breadcrumbs" aria-label="Breadcrumb">
<ol><li><a href="/">Home</a></li><li aria-current="page">Caesar Cipher</li></ol>
</nav>
<main>
<p class="intro">Encrypt and decrypt text with a <strong>Caesar shift cipher</strong>, apply <strong>ROT13</strong>, or paste a secret message and <strong>crack it instantly</strong> by trying all 25 shifts. Everything runs in your browser; nothing is uploaded.</p>
<div class="playground-card">
<div class="controls-grid">
<div class="control-group">
<div class="control-label">
<span>Shift Key</span>
<span class="shift-badge" id="shiftDisplay">Shift: 3</span>
</div>
<div class="slider-wrapper">
<input type="range" id="shiftRange" min="0" max="25" value="3" />
</div>
</div>
<div class="control-group">
<div class="control-label">Mode & Presets</div>
<div class="btn-group">
<button class="btn active" id="btnEncrypt">Encrypt</button>
<button class="btn" id="btnDecrypt">Decrypt</button>
<button class="btn" id="btnRot13">ROT13 (13)</button>
<button class="btn" id="btnReset">Reset (0)</button>
</div>
</div>
</div>
<div class="alphabet-mapping" id="alphabetMapping">
Plain: <span class="plain">A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</span><br />
Shift: <span class="cipher">D E F G H I J K L M N O P Q R S T U V W X Y Z A B C</span>
</div>
<div class="editors-grid">
<div class="editor-pane">
<div class="pane-header">
<span id="inputLabel">Plaintext Input</span>
<span id="inputLength">17 chars</span>
</div>
<textarea id="inputText" placeholder="Type or paste text to encrypt/decrypt...">Hello, World! 123</textarea>
</div>
<div class="editor-pane">
<div class="pane-header">
<span id="outputLabel">Ciphertext Output</span>
<button class="copy-btn" id="btnCopyOutput">Copy Output</button>
</div>
<textarea id="outputText" readonly placeholder="Output will appear here..."></textarea>
</div>
</div>
<div class="share-row">
<button class="btn primary" id="btnShare">🔗 Share as a challenge</button>
<span>Sends the encrypted text only; your friend has to crack it.
Want a short link and to see who clicked? <a id="minifynShare" href="https://www.minifyn.com/?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=share" target="_blank" rel="noopener">Shorten it with MiniFyn →</a></span>
</div>
</div>
<div class="cracker-section">
<div>
<h2 class="section-title">Cryptanalysis Cracker</h2>
<p class="section-desc">Instantly view all 25 possible Caesar shift permutations for the text above. Click any card to copy.</p>
</div>
<div class="cracker-grid" id="crackerGrid">
<!-- Permutation cards populated via JS -->
</div>
</div>
<section class="promo" aria-labelledby="promoTitle">
<div>
<h2 class="section-title" id="promoTitle">Free privacy & sharing tools from MiniFyn</h2>
<p class="section-desc">This playground is made by the team behind <a href="https://www.minifyn.com/?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=promo-intro" target="_blank" rel="noopener" style="color:#a78bfa">MiniFyn</a>, the simplest way to shorten, share, and track your links.</p>
</div>
<div class="promo-grid">
<a class="promo-card" href="https://gykh.sylvesterdas.com/morse/">
<strong>📡 Morse Code</strong>
<span>Type text, hear the beeps and watch the light flash. Decode Morse back to text.</span>
<em>Try it →</em>
</a>
<a class="promo-card" href="https://www.minifyn.com/?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=promo-minifyn" target="_blank" rel="noopener">
<strong>🔗 MiniFyn</strong>
<span>Lightning-fast edge link shortening, bio-links, QR code generator and link analytics with built-in threat protection.</span>
<em>Shorten a link free →</em>
</a>
<a class="promo-card" href="https://www.minifyn.com/scamguard?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=promo-scamguard" target="_blank" rel="noopener">
<strong>🛡️ ScamGuard</strong>
<span>Decoded a suspicious link? Inspect links, QR codes and redirect chains for phishing before you open them.</span>
<em>Check a link →</em>
</a>
<a class="promo-card" href="https://www.minifyn.com/censorfyn?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=promo-censorfyn" target="_blank" rel="noopener">
<strong>🙈 CensorFyn</strong>
<span>Auto-detect and irreversibly redact faces, passports, credit cards, PII text and QR codes, 100% offline.</span>
<em>Redact media →</em>
</a>
<a class="promo-card" href="https://www.minifyn.com/clipfyn?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=promo-clipfyn" target="_blank" rel="noopener">
<strong>🎬 ClipFyn</strong>
<span>Inspect, crop and fit videos on-device for compatible sharing, with no quality loss or uploads.</span>
<em>Prep a video →</em>
</a>
</div>
<p class="section-desc">Get them free:
<a href="https://chromewebstore.google.com/detail/scamguard-link-checker/cendbppkhplamddjfnbhgbejnpmfmlbi?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=promo-stores" target="_blank" rel="noopener" style="color:#a78bfa">ScamGuard for Chrome</a> ·
<a href="https://play.google.com/store/apps/details?id=com.minifyn.linkguard&referrer=utm_source%3Dcaesar-cipher%26utm_medium%3Dreferral%26utm_campaign%3Dplayground%26utm_content%3Dpromo-stores" target="_blank" rel="noopener" style="color:#a78bfa">ScamGuard for Android</a> ·
<a href="https://play.google.com/store/apps/details?id=com.minifyn.censorfyn&referrer=utm_source%3Dcaesar-cipher%26utm_medium%3Dreferral%26utm_campaign%3Dplayground%26utm_content%3Dpromo-stores" target="_blank" rel="noopener" style="color:#a78bfa">CensorFyn for Android</a> ·
<a href="https://play.google.com/store/apps/details?id=com.minifyn.clipfyn&referrer=utm_source%3Dcaesar-cipher%26utm_medium%3Dreferral%26utm_campaign%3Dplayground%26utm_content%3Dpromo-stores" target="_blank" rel="noopener" style="color:#a78bfa">ClipFyn for Android</a>
</p>
</section>
<section class="content">
<div>
<h2>What is a Caesar cipher?</h2>
<p>A Caesar cipher is one of the oldest encryption techniques. Each letter is replaced by the letter a fixed number of positions further along the alphabet, wrapping from Z back to A. With a shift of 3, <code>A → D</code> and <code>HELLO → KHOOR</code>.</p>
<p>It is named after Julius Caesar, who used a shift of 3 to protect his private letters. Numbers, spaces and punctuation stay unchanged.</p>
</div>
<div>
<h2>How to decode a Caesar cipher</h2>
<ol>
<li><strong>Know the shift?</strong> Choose <em>Decrypt</em>, set the shift, and paste the message.</li>
<li><strong>No key?</strong> Paste it anyway. The Cryptanalysis Cracker shows all 25 shifts; pick the line that reads as normal text.</li>
<li><strong>ROT13?</strong> Press <em>ROT13</em>. The same shift both encodes and decodes.</li>
</ol>
</div>
<div>
<h2>Use it in your code</h2>
<p>Everything on this page is available as a free, MIT-licensed, zero-dependency npm package with TypeScript types.</p>
<pre>npm install @gykh/caesar-cipher
import { encryptString, crack } from "@gykh/caesar-cipher";
encryptString("Hello", 3); // "Khoor"</pre>
<p><a href="https://github.com/get-your-knowledge-here/caesar-cipher" target="_blank" rel="noopener">Star it on GitHub</a> · <a href="https://www.npmjs.com/package/@gykh/caesar-cipher" target="_blank" rel="noopener">View on npm</a></p>
</div>
<div class="faq">
<h2>Frequently asked questions</h2>
<details>
<summary>What is ROT13?</summary>
<p>ROT13 is a Caesar cipher with a shift of 13. The alphabet has 26 letters, so applying ROT13 twice returns the original text. It is popular for hiding spoilers and puzzle answers.</p>
</details>
<details>
<summary>Is the Caesar cipher secure?</summary>
<p>No. With only 25 possible keys it can be broken in seconds, as the cracker above shows. Use it for puzzles, escape rooms, geocaching, teaching and games, never for real secrets.</p>
</details>
<details>
<summary>Is my text sent to a server?</summary>
<p>No. All encryption, decryption and cracking runs locally in your browser. Challenge links carry only the encrypted text, inside the link itself.</p>
</details>
<details>
<summary>How do I share a secret message?</summary>
<p>Encrypt your text, press <em>Share as a challenge</em>, and send the link. Your friend sees only the scrambled text and has to crack it. To get a short, tidy link and see how many people opened it, <a href="https://www.minifyn.com/?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=faq" target="_blank" rel="noopener">shorten it with MiniFyn</a>.</p>
</details>
</div>
</section>
</main>
<div class="toast" id="toast">Copied to clipboard!</div>
<footer>
<p>MIT License © 2021-2026 <a href="https://github.com/get-your-knowledge-here/caesar-cipher" target="_blank" rel="noopener">get-your-knowledge-here</a> • Created by <a href="https://www.sylvesterdas.com" target="_blank" rel="noopener">Sylvester Das</a></p>
<p>A free tool by <a href="https://www.minifyn.com/?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=footer" target="_blank" rel="noopener">MiniFyn</a>: the simplest way to shorten, share, and track your links · <a href="https://www.minifyn.com/scamguard?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=footer" target="_blank" rel="noopener">ScamGuard</a> · <a href="https://www.minifyn.com/censorfyn?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=footer" target="_blank" rel="noopener">CensorFyn</a> · <a href="https://www.minifyn.com/clipfyn?utm_source=caesar-cipher&utm_medium=referral&utm_campaign=playground&utm_content=footer" target="_blank" rel="noopener">ClipFyn</a></p>
</footer>
<script>
// Core Caesar Cipher Logic
const UPPER_A = 65, UPPER_Z = 90, LOWER_A = 97, LOWER_Z = 122, ALPHABET_LEN = 26;
function shiftCode(code, key) {
const shift = ((key % ALPHABET_LEN) + ALPHABET_LEN) % ALPHABET_LEN;
if (code >= UPPER_A && code <= UPPER_Z) {
return UPPER_A + ((code - UPPER_A + shift) % ALPHABET_LEN);
}
if (code >= LOWER_A && code <= LOWER_Z) {
return LOWER_A + ((code - LOWER_A + shift) % ALPHABET_LEN);
}
return code;
}
function cipherString(str, key) {
let result = '';
for (let i = 0; i < str.length; i++) {
result += String.fromCharCode(shiftCode(str.charCodeAt(i), key));
}
return result;
}
// UI Elements
const shiftRange = document.getElementById('shiftRange');
const shiftDisplay = document.getElementById('shiftDisplay');
const inputText = document.getElementById('inputText');
const outputText = document.getElementById('outputText');
const inputLabel = document.getElementById('inputLabel');
const outputLabel = document.getElementById('outputLabel');
const inputLength = document.getElementById('inputLength');
const alphabetMapping = document.getElementById('alphabetMapping');
const crackerGrid = document.getElementById('crackerGrid');
const toast = document.getElementById('toast');
const btnEncrypt = document.getElementById('btnEncrypt');
const btnDecrypt = document.getElementById('btnDecrypt');
const btnRot13 = document.getElementById('btnRot13');
const btnReset = document.getElementById('btnReset');
const btnCopyOutput = document.getElementById('btnCopyOutput');
let mode = 'encrypt'; // 'encrypt' or 'decrypt'
function updateAlphabetPreview(key) {
const effectiveShift = mode === 'encrypt' ? key : -key;
const plainLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
let shiftedLetters = '';
for (let i = 0; i < 26; i++) {
shiftedLetters += String.fromCharCode(shiftCode(plainLetters.charCodeAt(i), effectiveShift));
}
alphabetMapping.innerHTML = `
Plain: <span class="plain">${plainLetters.split('').join(' ')}</span><br />
Shift: <span class="cipher">${shiftedLetters.split('').join(' ')}</span>
`;
}
function updateConversion() {
const key = parseInt(shiftRange.value, 10);
shiftDisplay.textContent = `Shift: ${key}`;
const text = inputText.value;
inputLength.textContent = `${text.length} chars`;
const effectiveKey = mode === 'encrypt' ? key : -key;
outputText.value = cipherString(text, effectiveKey);
updateAlphabetPreview(key);
updateCrackerGrid(text);
}
function updateCrackerGrid(text) {
crackerGrid.innerHTML = '';
if (!text.trim()) {
crackerGrid.innerHTML = '<div style="color: var(--text-muted); font-size: 0.85rem;">Enter text above to see permutations.</div>';
return;
}
for (let s = 1; s < 26; s++) {
const cracked = cipherString(text, -s);
const card = document.createElement('div');
card.className = 'crack-card';
card.innerHTML = `
<div class="crack-card-header">
<span>Shift -${s}</span>
<span>Click to copy</span>
</div>
<div class="crack-card-text">${escapeHtml(cracked)}</div>
`;
card.addEventListener('click', () => {
copyToClipboard(cracked);
});
crackerGrid.appendChild(card);
}
}
function escapeHtml(str) {
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(() => {
showToast();
});
}
function showToast(message = 'Copied to clipboard!') {
toast.textContent = message;
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, message.length > 30 ? 3200 : 1800);
}
// Event Listeners
shiftRange.addEventListener('input', updateConversion);
inputText.addEventListener('input', updateConversion);
btnEncrypt.addEventListener('click', () => {
mode = 'encrypt';
btnEncrypt.classList.add('active');
btnDecrypt.classList.remove('active');
inputLabel.textContent = 'Plaintext Input';
outputLabel.textContent = 'Ciphertext Output';
updateConversion();
});
btnDecrypt.addEventListener('click', () => {
mode = 'decrypt';
btnDecrypt.classList.add('active');
btnEncrypt.classList.remove('active');
inputLabel.textContent = 'Ciphertext Input';
outputLabel.textContent = 'Plaintext Output';
updateConversion();
});
btnRot13.addEventListener('click', () => {
shiftRange.value = 13;
updateConversion();
});
btnReset.addEventListener('click', () => {
shiftRange.value = 0;
updateConversion();
});
btnCopyOutput.addEventListener('click', () => {
if (outputText.value) {
copyToClipboard(outputText.value);
}
});
// Challenge links: #c=<ciphertext> opens in decrypt mode with shift 0,
// so the recipient has to find the key with the cracker.
const btnShare = document.getElementById('btnShare');
btnShare.addEventListener('click', async () => {
const cipher = mode === 'encrypt' ? outputText.value : inputText.value;
if (!cipher.trim()) return;
const url = `${location.origin}${location.pathname}#c=${encodeURIComponent(cipher)}`;
const shareData = { title: 'Can you crack my Caesar cipher?', text: 'Can you crack this secret message?', url };
if (navigator.share && matchMedia('(pointer: coarse)').matches) {
try { await navigator.share(shareData); return; } catch (e) { if (e.name === 'AbortError') return; }