Q

Home » Top Secret » Simple Cypher Decoder in Visual Basic 6.0

Simple Cypher Decoder in Visual Basic 6.0

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 43 other followers

I was playing the old school Leather Goddess of Phobos from Infocom, when I ran into a keyword ‘in game’ which said I was in SUGGESTIVE mode.

Trying to test out the different modes was turning up nothing, I tried “Profane”, “Clean”, “Not Suggestive”, but with each the parser was rejecting.

So I did what I deplore doing. I broke open the user manual.

Which turns out to be a comic book.

And I do so enjoy my comic books.

And I was sidetracked when I got a few pages in from my attempts to find different modes – by this page.

simplecypher

A simple cypher string of letters that are meaningless, as the comic book text suggested, as one of the characters says ‘to decode, d becomes a, e becomes b, and so on’

And on the next page the message comes out:

simplecypher3

“The invasion force of the leather goddesses is based on the banks of the grand canal of Mars”

So looking at the number of characters of the original message, 53 to be precise,  the message the comic had was 92 characters in length. So I was curious. What, precisely, was the original message?

So I whipped up a quick little Visual Basic 6.0 program which did the conversion.

So what I did was I created a single form with a big button that says Decode! on it.

Like this:

vbprogram

Now in the code behind that button, I typed this code out – which – with comments in green – explains exactly what I did and why I did it.

To put it in layman’s terms, I create two string variables – one – a source string I called ‘sFrom’ which contains the text to decode “WKH EDWWOH RQ PDUV — RQ WKH EDQNV RI WKH JUDQG FDQDO”, the next, ‘sTo’ – which is to contain the decoded text.

From there, I count the number of characters in that text to decode, and for every character, I convert it to something called an ascii value – which is a numeric representation of the character value and it’s position in the alphabet.

Here’s an ascii chart to show the ascii values (I’m interested in the DECimal column):

ascii11

From there, for every character I receive, I convert it to numeric form, I subtract 3 from the value, then I reconvert it back over to a character form. The result is a quick decoding of the original string text, so D becomes 68 minus 3 equals 65 becomes A when you convert it back to a character. E(69) becomes B(69-3=66) and so on….

Here’s the source code:

cmddecode

I tweaked the code a little to ignore the ‘space’ and ‘-‘ without converting those, another way I could have done this was checked to see if the character was a letter. But this way worked fine for this little test.

And from there – if you see at the bottom of this code – the MSGBOX function puts a message box with the decoded text displayed to me – the user.

Here’s the message it displays:

battle

So as you can see, while the comic’s message was definitely longer, the gyst of the message was there. “WKH EDWWOH RQ PDUV — RQ WKH EDQNV RI WKH JUDQG FDQDO” converts to “THE BATTLE ON MARS — ON THE BANKS OF THE GRAND CANAL” when taking every character and shifting it three characters in the alphabet.

Now this little cypher would have a problem if the message contained the characters X, Y, and Z, which it didn’t, and would have contained special characters and punctuation marks if it leveraged Ascii like I did.

Enjoy!

Here’s the original source code for the cypher, contained in a JPG image. Download the image file, and leverage the ‘Open With’ command and open the image with 7-zip, then save the source code accordingly.

haveacow

 

 


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to follow this blog and receive notifications of new posts by email.