Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Decipher a Caesar-enciphered string
| ResourceFunction["CaesarDecipher"][string,n] deciphers a Caesar-enciphered string that was enciphered by shifting letters in string by n places further in the Latin alphabet. | |
| ResourceFunction["CaesarDecipher"][{s1,s2,…},n] deciphers each string si. | |
| ResourceFunction["CaesarDecipher"][n] represents an operator form of ResourceFunction["CaesarDecipher"] that can be applied to an expression. | 

Perform a Caesar decipher with a shift of 2:
| In[1]:= | ![ResourceFunction["CaesarDecipher"]["cdefg", 2]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/70a400c76a19944c.png) | 
| Out[1]= |  | 
Decipher a text by shifting the letters 9 positions back:
| In[2]:= | ![ResourceFunction["CaesarDecipher"]["Bjwmna", 9]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/695d4c27ea9951c4.png) | 
| Out[2]= |  | 
Cipher/decipher using a shift of n=13, also known at the ROT13 cipher:
| In[3]:= | ![ResourceFunction["CaesarDecipher"]["Cheers!"]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/7f42c746ec4d1380.png) | 
| Out[3]= |  | 
| In[4]:= | ![ResourceFunction["CaesarDecipher"]["Purref!"]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/6967c375db9231a9.png) | 
| Out[4]= |  | 
Decipher multiple strings:
| In[5]:= | ![ResourceFunction["CaesarDecipher"][{"Fbjxtrj", "ijanq", "junh"}, 5]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/52b87887c00d8120.png) | 
| Out[5]= |  | 
Create an operator form of the function that deciphers with a shift of 5:
| In[6]:= | ![op = ResourceFunction["CaesarDecipher"][5]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/780cacf8de6fe81f.png) | 
| Out[6]= |  | 
Use the operator:
| In[7]:= | ![op["junh"]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/2405aefc16b62965.png) | 
| Out[7]= |  | 
Decipher a message:
| In[8]:= | ![ResourceFunction[
 "CaesarDecipher"]["Ocdn dn v yzxdkczmzy hznnvbz ajm tjp!", 21]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/7e98171fbadf3787.png) | 
| Out[8]= |  | 
Decipher a message:
| In[9]:= | ![ResourceFunction[
 "CaesarDecipher"]["Iushuj cuiiqwu: Jxu Mebvhqc bqdwkqwu yi vkd!", 16]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/1f212692329cd19c.png) | 
| Out[9]= |  | 
Enciphering can be done using the deciphering function but with a negative shift:
| In[10]:= | ![ResourceFunction["CaesarCipher"]["This is a test.", 10] === ResourceFunction["CaesarDecipher"]["This is a test.", -10]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/3af9af38c7a85eed.png) | 
| Out[10]= |  | 
If the shift is an integer multiple of 26, the Caesar decipher does not affect the input string:
| In[11]:= | ![Table[ResourceFunction["CaesarDecipher"]["Input equals output.", i 26], {i, -3, 3}]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/772b268259b26107.png) | 
| Out[11]= |  | 
Try out all 25 options to decipher a message and find the original message:
| In[12]:= | ![Grid[Table[{i, ResourceFunction["CaesarDecipher"][
    "Hsle td esp dpncpe xpddlrp esle hp hlye?", i]}, {i, 25}]]](https://www.wolframcloud.com/obj/resourcesystem/images/52d/52d7930e-792c-46cc-bbb5-35e39b217334/06c0bcdf9def62f6.png) | 
| Out[12]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License