Tag Archives: Cipher

VBA: How to Crack the Caesar Shift with Brute Force

Caesar Brute Force

Imagine you have a combination lock with 4 digits. If you wack your head against a car hood by accident and forget the combination, this means you have a problem with 255 wrong answers and 1 right one. If you had a few days to spare, you could try all of them. The marvelous thing about computers is that they can, quite easily, auto-generate all 256 possibilities and beat the lock senseless with them. Until it opens.

That’s a brute force attack.

Continue reading

Tagged , , , , , , ,

Processing: How to Code A Wheel Cipher Layout

Thomas Jefferson's Wheel

I’ve been reading Code Breakers by Rudolf Kippenhahn. What hooked me into it was the part about the Wheel Cipher, a device envisioned by Thomas Jefferson in the late 1700’s. You can see Jefferson’s note about the wheel in his very own, genuinely awful handwriting here.

Continue reading

Tagged , , , , , , , ,

Processing: How to Code a Grayscale Cipher

A grey alphabet

Well, I’ve clearly been doing graphics wrong ALL MY LIFE because I never knew Processing was a thing. Now that I’m aware, I’m attempting to rewire my brain for it.

Continue reading

Tagged , , , , , , ,

Python: How to Cipher in Blender

An adorable little house...

I like shift ciphers as much as the next guy but Caesar is just so damn obvious. If you’re sending a giant wall of nonsense letters to a friend in an email, you might as well wave a giant neon-colored flag around that says “HEY I’M A SHADY BASTARD” to any third parties that might stumble upon it.

A proper cipher should have some form of camouflage. Like a sweet little house on a hill. With fireflies hanging out.

Continue reading

Tagged , , , , , , , , ,

AHK: Visualizing ELSE/IF with Arrays

So Hopper’s Amazing Decipherer Script 1.0 was about 472 lines because it included ELSE IF clauses for every letter in the alphabet.

HADS 2.0 cuts it down to 77 lines because arrays, as it turns out, are incredibly useful when paired with loops.

Making a Rotated Alphabet

Deciphering a Caesar cipher requires that the alphabet be moved up by a certain number. Like so.

ROTchart

Notice that this is basically a 2-step process. Turn the letters of the alphabet into numbers 1-26. Then add the rotational value to each of them to find their new positions, in the code below that’s assigned to a variable called indexVar. In ROT1, A =1 and the rotational value is 1, so A = 1+1 = 2.

But what happens when you hit Z? Z=26 and the rotation is 1, so Z =  26+1 = 27.

So, you want to tell the computer IF the number goes above 27, then you want to reset it to 1 and continue.

A Slow Motion Loop

Continue reading

Tagged , , , , , , , ,

AHK: What is an Array?

Arrays are a damn godsend. More specifically, they’re an easy way to deal with large lists. Why is this useful you ask? Imagine you want to run the same code on multiple items. The items could be numbers, letters, words, full sentences—anything.  By putting those things in a list, or an array, you can loop through hundreds, even thousands, of items with just a few lines of code.

ArrayGif1

Continue reading

Tagged , , , , ,

AHK: How to Decipher the Caesar Shift with Code

VG JNF N OEVTUG PBYQ QNL VA NCEVY NAQ GUR PYBPXF JRER FGEVXVAT GUVEGRRA JVAFGBA FZVGU UVF PUVA AHMMYRQ VAGB UVF OERNFG VA NA  RSSBEG GB RFPNCR GUR IVYR JVAQ FYVCCRQ DHVPXYL GUEBHTU GUR TYNFF QBBEF BS IVPGBEL ZNAFVBAF GUBHTU ABG DHVPXYL RABHTU GB CERIRAG N FJVEY BS TEVGGL QHFG SEBZ RAGREVAT NYBAT JVGU UVZ

-No idea what this says. Damn you, Caesar.

The Caesar Shift is supposed to be ridiculously easy to decipher. I say supposed to be because while it might be easy to crack, translating the bastard is mind-numbingly painful if you have a substantial block of text.

There are quite a few resources online that’ll do it for you, but for kicks, I wrote an AHK that automates it—if you know how many positions you want to shift.

So How Does the Shift Work?

Continue reading

Tagged , , , , ,