Wolfram Research

Function Repository Resource:

PigpenCipher

Source Notebook

Encipher a string using the pigpen cipher

Contributed by: Sander Huisman

ResourceFunction["PigpenCipher"][string]

enciphers string using a common version of the pigpen cipher.

Details and Options

ResourceFunction["PigpenCipher"] outputs a Graphics object with Line and Disk primitives.
ResourceFunction["PigpenCipher"] enciphers uses graphical symbols based on the following diagram:

Newlines (\n) in the text result in the characters being printed on to the next line.
Spaces (" ") leave a white area the same size as a letter.
The case of the letters is ignored.
RemoveDiacritics is used to convert as many letters as possible to regular letters of the Latin alphabet.
Any character other than az, AZ, " " (space), and \n (newline) is ignored.
ResourceFunction["PigpenCipher"] has the attribute Listable.

Examples

Basic Examples

Encipher a string:

In[1]:=
ResourceFunction["PigpenCipher"]["Wolfram Language is fun"]
Out[1]=

Scope

Spaces and newlines are enciphered:

In[2]:=
ResourceFunction["PigpenCipher"]["this is a\nmultiline\nsentence"]
Out[2]=

The case is ignored:

In[3]:=
ResourceFunction["PigpenCipher"]["aA\nbB\ncC\ndD\neE\nfF"]
Out[3]=

PigpenCipher automatically threads over a list of strings:

In[4]:=
ResourceFunction["PigpenCipher"][{"s", "a", "n", "d", "e", "r"}]
Out[4]=

Applications

Encipher a secret message:

In[5]:=
ResourceFunction["PigpenCipher"]["X marks the spot!"]
Out[5]=

Properties and Relations

Letters with diacritics are converted using RemoveDiacritics:

In[6]:=
ResourceFunction["PigpenCipher"]["piñata"]
Out[6]=

PigpenCipher outputs a Graphics object:

In[7]:=
Head[ResourceFunction["PigpenCipher"]["Wolfram"]]
Out[7]=

Possible Issues

Numbers, characters from other alphabets and punctuation are ignored:

In[8]:=
ResourceFunction[
 "PigpenCipher"]["this, 1337, \[Pi]\[Alpha]\[Nu]\[Tau]\[Alpha] \[Rho]\
\[CurlyEpsilon]\[Iota]."]
Out[8]=

Neat Examples

Separate pigpen ciphers do not make any sense:

In[9]:=
str1 = " h s i   u t a t s ";
str2 = "T i   s j s     e t";
{ResourceFunction["PigpenCipher"][str1], ResourceFunction["PigpenCipher"][str2]}
Out[11]=

Overlapping the Graphics objects interleaves the characters and reveals the message:

In[12]:=
Show[{ResourceFunction["PigpenCipher"][str1], ResourceFunction["PigpenCipher"][str2]}]
Out[12]=

Make a drawing using PigpenCipher:

In[13]:=
ResourceFunction[
 "PigpenCipher"]["   h   h     \n  i g i g\n i   b   g\n c       a\n  \
c     a\n   c   a\n    c a\n     b"]
Out[13]=

Resource History

Source Metadata

See Also

License Information