[{"data":1,"prerenderedAt":800},["ShallowReactive",2],{"guide-caesar-cipher-vs-rot13":3},{"id":4,"title":5,"body":6,"date":792,"description":793,"extension":794,"meta":795,"navigation":300,"path":796,"readingTime":291,"seo":797,"stem":798,"__hash__":799},"guides\u002Fguides\u002Fcaesar-cipher-vs-rot13.md","Caesar Cipher vs ROT13 Compared",{"type":7,"value":8,"toc":785},"minimark",[9,13,18,26,119,122,343,350,417,421,428,481,484,488,491,498,617,623,671,674,680,684,687,690,693,697,700,773,781],[10,11,12],"p",{},"ROT13 is the most famous member of the Caesar cipher family — a substitution cipher where each letter is shifted by a fixed number of positions in the alphabet. Julius Caesar reportedly used a shift of 3 for military correspondence. ROT13 uses a shift of 13, which creates a peculiar property: applying it twice returns the original text. Understanding how these ciphers relate and where they fall apart teaches fundamental concepts in cryptography without requiring any advanced math.",[14,15,17],"h2",{"id":16},"the-caesar-cipher-family","The Caesar Cipher Family",[10,19,20,21,25],{},"A Caesar cipher shifts every letter by a constant ",[22,23,24],"code",{},"n"," positions, wrapping around at the end of the alphabet. With 26 letters, there are only 25 non-trivial shifts (shift of 0 or 26 leaves text unchanged).",[27,28,29,51],"table",{},[30,31,32],"thead",{},[33,34,35,39,42,45,48],"tr",{},[36,37,38],"th",{},"Shift",[36,40,41],{},"A →",[36,43,44],{},"B →",[36,46,47],{},"C →",[36,49,50],{},"Z →",[52,53,54,72,87,104],"tbody",{},[33,55,56,60,63,66,69],{},[57,58,59],"td",{},"1",[57,61,62],{},"B",[57,64,65],{},"C",[57,67,68],{},"D",[57,70,71],{},"A",[33,73,74,77,79,82,85],{},[57,75,76],{},"3",[57,78,68],{},[57,80,81],{},"E",[57,83,84],{},"F",[57,86,65],{},[33,88,89,92,95,98,101],{},[57,90,91],{},"13",[57,93,94],{},"N",[57,96,97],{},"O",[57,99,100],{},"P",[57,102,103],{},"M",[33,105,106,109,112,114,116],{},[57,107,108],{},"25",[57,110,111],{},"Z",[57,113,71],{},[57,115,62],{},[57,117,118],{},"Y",[10,120,121],{},"The encryption function:",[123,124,129],"pre",{"className":125,"code":126,"language":127,"meta":128,"style":128},"language-javascript shiki shiki-themes github-light github-dark","function caesarEncrypt(text, shift) {\n  return text.replace(\u002F[a-zA-Z]\u002Fg, char => {\n    const base = char \u003C= 'Z' ? 65 : 97\n    return String.fromCharCode(((char.charCodeAt(0) - base + shift) % 26) + base)\n  })\n}\n\ncaesarEncrypt('HELLO', 3)   \u002F\u002F 'KHOOR'\ncaesarEncrypt('HELLO', 13)  \u002F\u002F 'URYYB'\n","javascript","",[22,130,131,161,199,232,283,289,295,302,324],{"__ignoreMap":128},[132,133,136,140,144,148,152,155,158],"span",{"class":134,"line":135},"line",1,[132,137,139],{"class":138},"szBVR","function",[132,141,143],{"class":142},"sScJk"," caesarEncrypt",[132,145,147],{"class":146},"sVt8B","(",[132,149,151],{"class":150},"s4XuR","text",[132,153,154],{"class":146},", ",[132,156,157],{"class":150},"shift",[132,159,160],{"class":146},") {\n",[132,162,164,167,170,173,175,179,183,185,188,190,193,196],{"class":134,"line":163},2,[132,165,166],{"class":138},"  return",[132,168,169],{"class":146}," text.",[132,171,172],{"class":142},"replace",[132,174,147],{"class":146},[132,176,178],{"class":177},"sZZnC","\u002F",[132,180,182],{"class":181},"sj4cs","[a-zA-Z]",[132,184,178],{"class":177},[132,186,187],{"class":138},"g",[132,189,154],{"class":146},[132,191,192],{"class":150},"char",[132,194,195],{"class":138}," =>",[132,197,198],{"class":146}," {\n",[132,200,202,205,208,211,214,217,220,223,226,229],{"class":134,"line":201},3,[132,203,204],{"class":138},"    const",[132,206,207],{"class":181}," base",[132,209,210],{"class":138}," =",[132,212,213],{"class":146}," char ",[132,215,216],{"class":138},"\u003C=",[132,218,219],{"class":177}," 'Z'",[132,221,222],{"class":138}," ?",[132,224,225],{"class":181}," 65",[132,227,228],{"class":138}," :",[132,230,231],{"class":181}," 97\n",[132,233,235,238,241,244,247,250,252,255,258,261,264,267,270,273,276,278,280],{"class":134,"line":234},4,[132,236,237],{"class":138},"    return",[132,239,240],{"class":146}," String.",[132,242,243],{"class":142},"fromCharCode",[132,245,246],{"class":146},"(((char.",[132,248,249],{"class":142},"charCodeAt",[132,251,147],{"class":146},[132,253,254],{"class":181},"0",[132,256,257],{"class":146},") ",[132,259,260],{"class":138},"-",[132,262,263],{"class":146}," base ",[132,265,266],{"class":138},"+",[132,268,269],{"class":146}," shift) ",[132,271,272],{"class":138},"%",[132,274,275],{"class":181}," 26",[132,277,257],{"class":146},[132,279,266],{"class":138},[132,281,282],{"class":146}," base)\n",[132,284,286],{"class":134,"line":285},5,[132,287,288],{"class":146},"  })\n",[132,290,292],{"class":134,"line":291},6,[132,293,294],{"class":146},"}\n",[132,296,298],{"class":134,"line":297},7,[132,299,301],{"emptyLinePlaceholder":300},true,"\n",[132,303,305,308,310,313,315,317,320],{"class":134,"line":304},8,[132,306,307],{"class":142},"caesarEncrypt",[132,309,147],{"class":146},[132,311,312],{"class":177},"'HELLO'",[132,314,154],{"class":146},[132,316,76],{"class":181},[132,318,319],{"class":146},")   ",[132,321,323],{"class":322},"sJ8bj","\u002F\u002F 'KHOOR'\n",[132,325,327,329,331,333,335,337,340],{"class":134,"line":326},9,[132,328,307],{"class":142},[132,330,147],{"class":146},[132,332,312],{"class":177},[132,334,154],{"class":146},[132,336,91],{"class":181},[132,338,339],{"class":146},")  ",[132,341,342],{"class":322},"\u002F\u002F 'URYYB'\n",[10,344,345,346,349],{},"Decryption applies the same function with ",[22,347,348],{},"26 - shift",":",[123,351,353],{"className":125,"code":352,"language":127,"meta":128,"style":128},"function caesarDecrypt(text, shift) {\n  return caesarEncrypt(text, 26 - shift)\n}\n\ncaesarDecrypt('KHOOR', 3)  \u002F\u002F 'HELLO'\n",[22,354,355,372,390,394,398],{"__ignoreMap":128},[132,356,357,359,362,364,366,368,370],{"class":134,"line":135},[132,358,139],{"class":138},[132,360,361],{"class":142}," caesarDecrypt",[132,363,147],{"class":146},[132,365,151],{"class":150},[132,367,154],{"class":146},[132,369,157],{"class":150},[132,371,160],{"class":146},[132,373,374,376,378,381,384,387],{"class":134,"line":163},[132,375,166],{"class":138},[132,377,143],{"class":142},[132,379,380],{"class":146},"(text, ",[132,382,383],{"class":181},"26",[132,385,386],{"class":138}," -",[132,388,389],{"class":146}," shift)\n",[132,391,392],{"class":134,"line":201},[132,393,294],{"class":146},[132,395,396],{"class":134,"line":234},[132,397,301],{"emptyLinePlaceholder":300},[132,399,400,403,405,408,410,412,414],{"class":134,"line":285},[132,401,402],{"class":142},"caesarDecrypt",[132,404,147],{"class":146},[132,406,407],{"class":177},"'KHOOR'",[132,409,154],{"class":146},[132,411,76],{"class":181},[132,413,339],{"class":146},[132,415,416],{"class":322},"\u002F\u002F 'HELLO'\n",[14,418,420],{"id":419},"the-self-inverting-property-of-rot13","The Self-Inverting Property of ROT13",[10,422,423,424,427],{},"ROT13 uses shift = 13. Because ",[22,425,426],{},"13 + 13 = 26"," (the alphabet length), applying ROT13 twice returns the original text. This makes ROT13 its own inverse — there is no separate encrypt and decrypt step.",[123,429,431],{"className":125,"code":430,"language":127,"meta":128,"style":128},"const encoded = caesarEncrypt('Secret message', 13)  \u002F\u002F 'Frperg zrffntr'\nconst decoded = caesarEncrypt(encoded, 13)            \u002F\u002F 'Secret message'\n",[22,432,433,459],{"__ignoreMap":128},[132,434,435,438,441,443,445,447,450,452,454,456],{"class":134,"line":135},[132,436,437],{"class":138},"const",[132,439,440],{"class":181}," encoded",[132,442,210],{"class":138},[132,444,143],{"class":142},[132,446,147],{"class":146},[132,448,449],{"class":177},"'Secret message'",[132,451,154],{"class":146},[132,453,91],{"class":181},[132,455,339],{"class":146},[132,457,458],{"class":322},"\u002F\u002F 'Frperg zrffntr'\n",[132,460,461,463,466,468,470,473,475,478],{"class":134,"line":163},[132,462,437],{"class":138},[132,464,465],{"class":181}," decoded",[132,467,210],{"class":138},[132,469,143],{"class":142},[132,471,472],{"class":146},"(encoded, ",[132,474,91],{"class":181},[132,476,477],{"class":146},")            ",[132,479,480],{"class":322},"\u002F\u002F 'Secret message'\n",[10,482,483],{},"This property is why ROT13 became popular for hiding spoilers: the same operation encodes and decodes, so readers can reveal the hidden text without a separate tool. Other Caesar shifts lack this property — shift of 3 requires shift of 23 to reverse.",[14,485,487],{"id":486},"why-neither-is-secure","Why Neither Is Secure",[10,489,490],{},"Both Caesar ciphers and ROT13 are trivially broken by anyone with basic cryptanalysis skills:",[10,492,493,497],{},[494,495,496],"strong",{},"Brute force",": There are only 25 possible shifts. An attacker tries all of them in milliseconds and reads the one that produces English text.",[123,499,501],{"className":125,"code":500,"language":127,"meta":128,"style":128},"function bruteForceCaesar(ciphertext) {\n  return Array.from({ length: 26 }, (_, shift) => ({\n    shift,\n    text: caesarEncrypt(ciphertext, shift),\n  }))\n}\n\nbruteForceCaesar('KHOOR').filter(r => r.text === 'HELLO')\n\u002F\u002F [{ shift: 23, text: 'HELLO' }] — found instantly\n",[22,502,503,517,550,555,565,570,574,578,612],{"__ignoreMap":128},[132,504,505,507,510,512,515],{"class":134,"line":135},[132,506,139],{"class":138},[132,508,509],{"class":142}," bruteForceCaesar",[132,511,147],{"class":146},[132,513,514],{"class":150},"ciphertext",[132,516,160],{"class":146},[132,518,519,521,524,527,530,532,535,538,540,542,544,547],{"class":134,"line":163},[132,520,166],{"class":138},[132,522,523],{"class":146}," Array.",[132,525,526],{"class":142},"from",[132,528,529],{"class":146},"({ length: ",[132,531,383],{"class":181},[132,533,534],{"class":146}," }, (",[132,536,537],{"class":150},"_",[132,539,154],{"class":146},[132,541,157],{"class":150},[132,543,257],{"class":146},[132,545,546],{"class":138},"=>",[132,548,549],{"class":146}," ({\n",[132,551,552],{"class":134,"line":201},[132,553,554],{"class":146},"    shift,\n",[132,556,557,560,562],{"class":134,"line":234},[132,558,559],{"class":146},"    text: ",[132,561,307],{"class":142},[132,563,564],{"class":146},"(ciphertext, shift),\n",[132,566,567],{"class":134,"line":285},[132,568,569],{"class":146},"  }))\n",[132,571,572],{"class":134,"line":291},[132,573,294],{"class":146},[132,575,576],{"class":134,"line":297},[132,577,301],{"emptyLinePlaceholder":300},[132,579,580,583,585,587,590,593,595,598,600,603,606,609],{"class":134,"line":304},[132,581,582],{"class":142},"bruteForceCaesar",[132,584,147],{"class":146},[132,586,407],{"class":177},[132,588,589],{"class":146},").",[132,591,592],{"class":142},"filter",[132,594,147],{"class":146},[132,596,597],{"class":150},"r",[132,599,195],{"class":138},[132,601,602],{"class":146}," r.text ",[132,604,605],{"class":138},"===",[132,607,608],{"class":177}," 'HELLO'",[132,610,611],{"class":146},")\n",[132,613,614],{"class":134,"line":326},[132,615,616],{"class":322},"\u002F\u002F [{ shift: 23, text: 'HELLO' }] — found instantly\n",[10,618,619,622],{},[494,620,621],{},"Frequency analysis",": Even without trying all shifts, the letter frequency distribution of English text is preserved under substitution. 'E' is the most common letter in English, so the most common letter in the ciphertext corresponds to 'E'.",[27,624,625,638],{},[30,626,627],{},[33,628,629,632,635],{},[36,630,631],{},"Letter",[36,633,634],{},"English Frequency",[36,636,637],{},"Caesar(3) Frequency",[52,639,640,650,661],{},[33,641,642,644,647],{},[57,643,81],{},[57,645,646],{},"12.7%",[57,648,649],{},"H appears at 12.7%",[33,651,652,655,658],{},[57,653,654],{},"T",[57,656,657],{},"9.1%",[57,659,660],{},"W appears at 9.1%",[33,662,663,665,668],{},[57,664,71],{},[57,666,667],{},"8.2%",[57,669,670],{},"D appears at 8.2%",[10,672,673],{},"A frequency table of the ciphertext reveals the shift immediately.",[10,675,676,679],{},[494,677,678],{},"No key space",": The shift value is the entire key. With only 25 possibilities, brute force is trivial. Modern ciphers use keys of 128+ bits, giving 2¹²⁸ possible keys — roughly 340 undecillion.",[14,681,683],{"id":682},"historical-context","Historical Context",[10,685,686],{},"Caesar ciphers were adequate for their era because literacy was rare and systematic cryptanalysis did not exist. By the 9th century, Arab scholars had documented frequency analysis, rendering all monoalphabetic substitution ciphers insecure.",[10,688,689],{},"ROT13 found a second life in the early internet era, not as encryption but as a convention for hiding content. On Usenet in the 1980s, people used ROT13 to obscure joke punchlines, movie spoilers, and potentially offensive material. The goal was never security — it was social convention, a way to let readers choose whether to see the content.",[10,691,692],{},"Modern platforms like Reddit still support ROT13 in comments for spoiler tags. Some email clients and newsreaders include built-in ROT13 decode functions. The convention persists because the self-inverting property makes it convenient, not because anyone believes it provides security.",[14,694,696],{"id":695},"when-to-use-rot13-today","When to Use ROT13 Today",[10,698,699],{},"ROT13 has exactly one legitimate use: obscuring text from casual glances where the reader actively wants to decode it. Spoilers, puzzle hints, and easter eggs are appropriate. Anything else — including \"light obfuscation\" of API keys, passwords, or sensitive data — is dangerously insecure.",[123,701,703],{"className":125,"code":702,"language":127,"meta":128,"style":128},"\u002F\u002F Appropriate: hiding a puzzle hint\nconst hint = caesarEncrypt('The safe is behind the painting', 13)\n\u002F\u002F Reader decodes when they want the hint\n\n\u002F\u002F Inappropriate: \"hiding\" an API key\nconst apiKey = caesarEncrypt('sk-live-abc123def456', 13)\n\u002F\u002F This provides zero security — anyone can decode it\n",[22,704,705,710,732,737,741,746,768],{"__ignoreMap":128},[132,706,707],{"class":134,"line":135},[132,708,709],{"class":322},"\u002F\u002F Appropriate: hiding a puzzle hint\n",[132,711,712,714,717,719,721,723,726,728,730],{"class":134,"line":163},[132,713,437],{"class":138},[132,715,716],{"class":181}," hint",[132,718,210],{"class":138},[132,720,143],{"class":142},[132,722,147],{"class":146},[132,724,725],{"class":177},"'The safe is behind the painting'",[132,727,154],{"class":146},[132,729,91],{"class":181},[132,731,611],{"class":146},[132,733,734],{"class":134,"line":201},[132,735,736],{"class":322},"\u002F\u002F Reader decodes when they want the hint\n",[132,738,739],{"class":134,"line":234},[132,740,301],{"emptyLinePlaceholder":300},[132,742,743],{"class":134,"line":285},[132,744,745],{"class":322},"\u002F\u002F Inappropriate: \"hiding\" an API key\n",[132,747,748,750,753,755,757,759,762,764,766],{"class":134,"line":291},[132,749,437],{"class":138},[132,751,752],{"class":181}," apiKey",[132,754,210],{"class":138},[132,756,143],{"class":142},[132,758,147],{"class":146},[132,760,761],{"class":177},"'sk-live-abc123def456'",[132,763,154],{"class":146},[132,765,91],{"class":181},[132,767,611],{"class":146},[132,769,770],{"class":134,"line":297},[132,771,772],{"class":322},"\u002F\u002F This provides zero security — anyone can decode it\n",[10,774,775,776,780],{},"Experiment with Caesar cipher shifts and ROT13 encoding at ",[777,778,779],"a",{"href":779},"\u002Ftools\u002Frot13",", which supports all 25 shifts with instant encoding and decoding for educational exploration.",[782,783,784],"style",{},"html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":128,"searchDepth":163,"depth":163,"links":786},[787,788,789,790,791],{"id":16,"depth":163,"text":17},{"id":419,"depth":163,"text":420},{"id":486,"depth":163,"text":487},{"id":682,"depth":163,"text":683},{"id":695,"depth":163,"text":696},"2026-05-28","How ROT13 relates to the Caesar cipher family and why both are educational, not secure.","md",{},"\u002Fguides\u002Fcaesar-cipher-vs-rot13",{"title":5,"description":793},"guides\u002Fcaesar-cipher-vs-rot13","0uCyLN9EHoXsOvUl843ToQYNee2bqP9Z8tFBSEt6Nlo",1780401332060]