Programming puzzles and other RPG tools with perl
Gamers love puzzles. Even better – gamers like challenging puzzles. In my far out alternate modern world of cyberpunk, the gaming PCs became engrossed in their first “real” puzzle of the campaign. The best thing about it was that not only was it a “real” challenge – but it used real modern technology.
My game system is GURPS. In the current campaign NPC D@rkSt4R has inconspicuously contacted each member of the team (PCs) and arranged an in person secret rendezvous. His prestigous reputation within the community lends him all the juice needed to pull these private tech junkies out of hiding. After arousing interest in a high paying opportunity – D@rkSt4R gets commitment from each colleague to begin work the next morning in the arranged location (his current abode). When the players arrive – they wait a painstakenly long time before they decide to break in the complex. Just after busting the entry bio scanner, an alarm cuts the air and the blues arrive in seconds (fast eh? strange). The officers arrest the group on suspicion of illegal activities. Hours later, exhausted and hungry – the team is interrogated over D@rkSt4R’s murder. Successful roleplaying convinced the investigators that the crew was innocent and, in exchange for liberty, secured their services for no less than 10 hours of work each. They were tasked with discovering the contents of a high-security military grade microchip (prop was a micro-sd card).”

The microchip contains an encrypted file using a centuries old Vigenere cipher. The team needed to figure out the cipher type, and the “secret key” – or password. I chose this cipher because this family of ciphers are relatively well known. They are also breakable without the need for complex computer analysis.
The challenge was straightforward enough:
- clue/prop: a military grade microchip (this was really just a microSD card)
- challenge: why did Darkstar have this in his possession at the time of his death? What was on it?
There’s that old adage that says if the only tool in your belt is a hammer – every problem looks like a nail. Well, I happen to possess quite the hammer in my belt, a Throngden Battle Hammer+2, it’s called Perl. The language of the Gods.. yes, BELIEVE IT! To your gaming delight I can show you why having this skill has taken my gamemastery to the next level (which is level 56).
The team took a while to figure out the cipher – and eventually elected to roll for the answer; I did, however, make them work for it by requesting they formulate their queries intelligently. For example: “what’s the cypher?” didn’t work – accepted form was: “is this a ROT13 cipher?…” and so on [INT or COMPUTER skill].
The password was a bit on the ridiculously tough side; and I suggest you figure out your own clever and simpler method instead. I copied system files from my computer onto the sd card – with the exception of any files that began with the password sequence (benqy). All other letters were represented in the file list. It was tough and the team spent a lot of time running this one down as well. Bad puzzle?
Once the team figured out the cipher – Google found them all the vigenere transformation tools they could ever use. If you’re wondering why I didn’t use an online tool to encrypt my message to begin with – it’s because my brain is wired the other way; I found it easier to implement the library in Perl!
With this in my back pocket – I can now reuse this program whenever I need to create an in game password challenge. Sweet!
So, now you’re wondering – “how do I get this to work for me?” – “is it easy to get it working on my computer?”. You tell me. Follow these steps to encrypt your own document in Vigenere using Perl.
- Install Perl – Activestate has a good Windows version that has a package manager
- lib YAML for Perl – windows users, use the PPM repository tool; others use
sudo cpan -i YAML - download this file bundle; it contains the crypt script and a config file
- extract bundle into a directory
- open a command prompt (or terminal)
- change to the directory that you unpacked the zip into
- write your plain text message in a file
- run the program with the filename of your plain text file as an argument
- the output is directed to the screen by default; you can force it into a file with the redirect command line operator:
>
In the next article I will demonstrate how I created a WebDAV HTTP file server with Perl on my home computer – and how the team used modern day hacking techniques to sniff out this file server over the Internet!















“The language of the Gods.. yes, BELIEVE IT!”
That’s not the question. The question is, WHICH gods?
I love perl, for the record. I don’t love that no one else /in my department/ knows it, so I’m all alone when it comes to fixing my mistakes.
@LordSpruge – The last time I thought about using computers as more than a simple aid, is when I was thinking of making a gaming table with built in data terminals (Yes, I mean data terminals, have an 8 port serial card and a Test dump Terminal.) I was thinking of writing software that would allow players to look up information on the “Galactic Encyclopedia” or local news network.
@Swordgleam – Several people around where I work know Perl. I’m the bastard child by knowing PHP of all things. I still know some basic Perl, although I’d have to be using a reference book for a while.