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 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 "a"–"z", "A"–"Z", " " (space) and "\n" (newline) is ignored.
ResourceFunction["PigpenCipher"] has the attribute Listable.

Examples

Basic Examples (1) 

Encipher a string:

In[1]:=
ResourceFunction[
 "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["Wolfram Language is fun"]
Out[1]=

Scope (3) 

Spaces and new lines are enciphered:

In[2]:=
ResourceFunction[
 "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["this is a\nmultiline\nsentence"]
Out[2]=

The case is ignored:

In[3]:=
ResourceFunction[
 "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["aA\nbB\ncC\ndD\neE\nfF"]
Out[3]=

PigpenCipher automatically threads over a List of strings:

In[4]:=
ResourceFunction[
 "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{"s", "a", "n", "d", "e", "r"}]
Out[4]=

Applications (1) 

Encipher a secret message:

In[5]:=
ResourceFunction[
 "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["X marks the spot!"]
Out[5]=

Properties and Relations (2) 

Letters with diacritics are converted using RemoveDiacritics:

In[6]:=
ResourceFunction[
 "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["piñata"]
Out[6]=

PigpenCipher outputs a Graphics object:

In[7]:=
Head[ResourceFunction[
  "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["Wolfram"]]
Out[7]=

Possible Issues (1) 

Numbers, characters from other alphabets and punctuation are ignored:

In[8]:=
ResourceFunction[
 "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["this, 1337, \[Pi]\[Alpha]\[Nu]\[Tau]\[Alpha] \[Rho]\[CurlyEpsilon]\[Iota]."]
Out[8]=

Neat Examples (2) 

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", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][str1], ResourceFunction[
  "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][str2]}
Out[11]=

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

In[12]:=
Show[{ResourceFunction[
   "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][str1], ResourceFunction[
   "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][str2]}]
Out[12]=

Make a drawing using PigpenCipher:

In[13]:=
ResourceFunction[
 "PigpenCipher", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["   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]=

Publisher

SHuisman

Version History

  • 1.1.0 – 09 June 2023
  • 1.0.0 – 03 July 2019

Source Metadata

Related Resources

License Information