Pigpen Cipher Encryption
Your mission is simple: to write a program which receives text as input and outputs an ASCII representation of it in the Pigpen Cipher.
Input
ASCII-only (no Unicode) characters. You must be able to handle at least 16384 characters and 256 lines.
Output
- Replace all characters which are not new lines or in
ABCDEFGHIJKLMNOPQRSTUVWXYZ
orabcdefghijklmnopqrstuvwxyz
with spaces. - Case-insensitively, replace each letter with its encrypted form (see next section), inserting a trailing space on each of the three lines after each. Each encoded character is a 3*3 block of ASCII art. Replace spaces with 3*3 blocks of spaces.
- All the characters should be on the same three lines (call these three lines one pigpen-line), unless there is a new line, which starts a new pigpen-line. Leave a normal line blank between pigpen-lines.
The Cipher
| | | |
.| |.| |.
--+ for J +-+ for K +-- for L
--+ +-+ +--
.| |.| |.
--+ for M +-+ for N +-- for O
--+ +-+ +--
.| |.| |.
| for P | | for Q | for R
(ABCDEFGHI are the same as JKLMNOPQR, but with the . replaced by a space)
\./
V for W (note the row of 3 spaces on the top)
^
/.\ for Z (note the 3 spaces on the bottom)
\
.>
/ for X (note the leading spaces)
/
<.
\ for Y (note extra trailing spaces)
(STUV are like WXYZ, but with the . replaced by a space)
Example
The input "hEllo,wORLd" should produce:
+-+ +-+ | | +-- +-- +-- | --+
| | | | |. |. |. \./ |. |. |. |
| | +-+ +-- +-- +-- V +-- | +-- --+
The base64 encoding of the above, with a trailing new line, is below. The md5sum is 6f8ff1fed0cca4dd0492f9728ea02e7b
.
Ky0rICstKyB8ICAgfCAgICstLSAgICAgICAgICstLSArLS0gfCAgIC0tKwp8IHwgfCB8IHwuICB8
LiAgfC4gICAgICBcLi8gfC4gIHwuICB8LiAgICB8CnwgfCArLSsgKy0tICstLSArLS0gICAgICBW
ICArLS0gfCAgICstLSAtLSsK
Without a trailing new line, the md5sum is 581005bef7ee76e24c019d076d5b375f
and the base64 is:
Ky0rICstKyB8ICAgfCAgICstLSAgICAgICAgICstLSArLS0gfCAgIC0tKwp8IHwgfCB8IHwuICB8
LiAgfC4gICAgICBcLi8gfC4gIHwuICB8LiAgICB8CnwgfCArLSsgKy0tICstLSArLS0gICAgICBW ICArLS0gfCAgICstLSAtLSs=
Rules
- Standard loopholes are forbidden.
- This is code golf. Shortest code wins.
- In languages which cannot accept multiple lines of input at a time (e.g. JavaScript with
prompt()
), use*
(or some other character) as a line separator.
Erranda
- The example was missing a few spaces (A space should consist of the trailing spaces of the previous character, if any, itself, and its own trailing spaces). This has now been fixed.
prompt
is used for input, but it accepts a single line only. Could I use a special char (like '*') to mark a new line in input?. \$\endgroup\$