10
1
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.
1I remember playing with this as a kid, but never knew the name of it. Thanks! – Geobits – 2014-09-11T19:30:39.527
Can I use a custom font? :-) – Florian F – 2014-09-11T19:47:57.073
@FlorianF No... – None – 2014-09-11T19:52:49.527
Coding in javascript. Usually
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?. – edc65 – 2014-09-13T18:04:35.483@edc65 Yes, you may – None – 2014-09-13T18:11:09.053
As pointed out by Claudiu, there are 4 spaces between Hello and World in your example. If I render a space as 3x3 chars block and add 1 space before and 1 space after, I get 5 spaces between words. Am I wrong? – edc65 – 2014-09-15T07:51:40.543
@edc65 no you aren't, thanks – None – 2014-09-15T10:37:38.300
@edc65 please edit it in – None – 2014-09-15T10:38:03.170
Next up: Run all the answers through themselves, whichever has the least spaces in it wins. – cjfaure – 2014-09-15T12:05:12.167
@professorfish: could you add md5s for the output if there are 5 spaces between words? I had that at first and had to add a few chars to handle 4 spaces. – Claudiu – 2014-09-15T14:59:33.277
@Claudiu I've fixed it – None – 2014-09-15T19:29:57.640