Wolfram Research

Function Repository Resource:

ChaoDecipher

Source Notebook

Decipher a Chaocipher-enciphered string

Contributed by: Sander Huisman

ResourceFunction["ChaoDecipher"][string,{αp,αc}]

deciphers string using the plain text alphabet αp and the cipher alphabet αc.

Details and Options

The alphabets αp and αc should be a permutation of the letters A-Z.
Any other letter than a-z and A-Z in string is ignored.
The output is in capital letters.
ResourceFunction["ChaoDecipher"] works by decoding each character in string (example: “AVSWQBHMEJT”) using the following steps:
The character “A” is looked up in the cipher alphabet (bottom), and one finds the corresponding letter in the plain alphabet (top):

the encoded letter is therefore "M".

Both alphabets are shifted to the left such as to bring the red letters to the front:

The plain alphabet (top) is shifted one more to the left:

Move the 3rd letter of the plain alphabet (top) and the 2 letter of the cipher alphabet (bottom) to the 14th position.

Continue with the next letter using the new alphabets:

Examples

Basic Examples

Decipher a piece of text using unshuffled plain and cipher alphabets:

In[1]:=
ResourceFunction[
 "ChaoDecipher"]["HDJHISUHBK", {CharacterRange["a", "z"], CharacterRange["a", "z"]}]
Out[1]=

Decode a string that returns a ‘constant’ string:

In[2]:=
ResourceFunction[
 "ChaoDecipher"]["AZYXWVUTSRQPOBAZYXWVUT", {CharacterRange["a", "z"], CharacterRange["a", "z"]}]
Out[2]=

Scope

Use random plain and cipher alphabets:

In[3]:=
pa = {"L", "Z", "G", "U", "Q", "A", "X", "B", "J", "R", "T", "F", "D",
    "K", "E", "N", "Y", "P", "S", "O", "C", "M", "W", "I", "H", "V"};
ca = {"G", "W", "Z", "J", "P", "Q", "V", "R", "D", "C", "H", "X", "S",
    "U", "T", "K", "M", "E", "O", "F", "Y", "A", "I", "L", "N", "B"};
encoded = ResourceFunction["ChaoDecipher"]["APIRHQBJMSXTZDCGWWEC", {pa, ca}]
Out[5]=

Properties and Relations

ChaoCipher can be used to encipher a string. First encode a piece of string:

In[6]:=
pa = "PTLNBQDEOYSFAVZKGJRIHWXUMC" // Characters;
ca = "HXUCZVAMDSLKPEFJRIGTWOBNYQ" // Characters;
encoded = ResourceFunction["ChaoCipher"][
  "WELLDONEISBETTERTHANWELLSAID", {pa, ca}]
Out[6]=

Now we can decipher it:

In[7]:=
ResourceFunction["ChaoDecipher"][encoded, {pa, ca}]
Out[7]=

Resource History

Source Metadata

Related Resources

License Information