Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Decipher a Vigenère-enciphered string
ResourceFunction["VigenereDecipher"][string,key] deciphers string using the key key. | |
ResourceFunction["VigenereDecipher"][string,{key1,key2,…}] repeatedly deciphers string using first key1, then key2, etc. | |
ResourceFunction["VigenereDecipher"][{s1,s2,…},key] deciphers the strings s1,s2, etc. using the key key. | |
ResourceFunction["VigenereDecipher"][key] represents an operator form of ResourceFunction["VigenereDecipher"] that can be applied to an expression. |
Decipher a message using the key "LEMON":
In[1]:= |
Out[1]= |
Decipher with multiple keys:
In[2]:= |
Out[2]= |
Decipher a message twice, first using "GO" and then with "CAT":
In[3]:= |
Out[3]= |
Decipher multiple strings:
In[4]:= |
Out[4]= |
Create an operator that deciphers strings with the key "sparks":
In[5]:= |
Out[5]= |
Apply the operator to a String:
In[6]:= |
Out[6]= |
If a single character is used, the Vigenère cipher is identical to a Caesar cipher:
In[7]:= |
Out[7]= |
When deciphering with multiple keys, the keys can first be enciphered with each other to decipher the message with a single key. The length of the replacing key has to be the LCM of the lengths of each of the keys:
In[8]:= |
Out[8]= |
This indeed matches with what you expect:
In[9]:= |
Out[9]= |
The case of the original text is retained; the case of the key does not matter:
In[10]:= |
Out[10]= |
In[11]:= |
Out[11]= |
VigenereDecipher is related to the resource function VigenereCipher:
In[12]:= |
Out[12]= |
Spaces and the letters "a" and "A" in the key will not alter the enciphered message:
In[13]:= |
Out[13]= |
The key should have valid letters and valid length:
In[14]:= |
Out[14]= |
In[15]:= |
Out[15]= |
In[16]:= |
Out[16]= |
Two keys can "negate" each other:
In[17]:= |
Out[17]= |
Enciphering the keys with each other gives a string with only "A"s:
In[18]:= |
Out[18]= |
This work is licensed under a Creative Commons Attribution 4.0 International License