Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Encipher a string using the rail fence cipher
ResourceFunction["RailFenceCipher"][string,n] enciphers string using the rail fence cipher with n rails. |

Encipher a string using the rail fence cipher on 3 rails:
| In[1]:= |
| Out[1]= |
The rail fence cipher is a transposition cipher, that is, the characters are scrambled rather than replaced:
| In[2]:= |
| Out[3]= |
The first character is not moved:
| In[4]:= |
| Out[5]= | ![]() |
If the number of rails is large compared to the length of the encoded message then a large part might be readable:
| In[6]:= |
| Out[6]= |
Decrease the number of lines to scramble the message:
| In[7]:= |
| Out[7]= |
Use a varying number of rails for the same message:
| In[8]:= |
| Out[8]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License