match ( '+', text ) is not None : # Mode: decode If '-r' in argv or '-reverse' in argv : reverse = True else : reverse = False # If it has numbers, then it must be ciphertext picode.py (options:, )" exit ( 1 ) def main ( argv ): if len ( argv ) < 2 : # Give it either plaintext or ciphertext it will determine which it isĮrror ( "Not enough arguments" ) text = argv code = PiCoder () # See if we need to reverse the Fibonacci sequence (for decoding and encoding) Import sys, re from picode_utils import * # Prints out the usage text along with any error messagesĭef error ( text = '' ): print text print "Usage. (For that matter, picode.py is also kind of too long for this page, but I wanted to try out Pygments.) #!/usr/bin/env python (below), and picode_utils.py - the latter was too long for this page. (Basically, you need the difference to be positive.) Then subtract it, and separate it into words depending on the 0’s, then refer to the pi-code chart to figure out the individual letters. How many digits you need depends on the encoded string - if the first two characters are 12 or less then you probably need one digit more than the length of the string. To decode it, you first need to remove all the letters. Who decided to make the letter O look just like 0, anyway?Īnd there you go. Go for lowercase, to prevent confusion with O and 0. To make it even more devious, we could make it look a bit like a longer md5 hash by adding random letters: This even acts as a bit of a salt, although it’s not an actual salt. Now there’s no pattern between 0’s at all. And this is still a monoalphabetic cipher, barely a step above the Polybius cipher once you figure out that 0 = space (not a difficult conclusion to make). (It appears around digit #33, incidentally.) In this version, we’ll keep it simple by replacing spaces with 0s.Ī bit better, but there’s still a pattern with the 0s, in that there is always an even number of digits between them. You could alternatively use any sequence of two digits starting with 0, or even something else entirely, but 0 is a good bet because it happens to not appear in the first 26 digits of pi. You could also replace them with any sequence of digits beginning and ending with a 0, which would result in some junk characters, but would also helps to ensure that you correctly decoded a message and nothing got lost, because you if you have an odd number of spaces then something is wrong. So let’s disguise them by replacing them with 0’s. This monoalphabetic substitution looks like this: So let’s say you wanted to encode the following sequence: lol mudkips lol We can then add that sequence to the ciphertext, resulting in an added layer of confusion and rendering frequency-based analysis almost useless. If we write it as a sequence without spaces, it looks like this: Now let’s make it a bit tricker with Fibonacci. Now, it’s pretty clear what we can do - assign each letter of the alphabet to a sequence of two letters. Then, underneath each digit, write out the number of times that digit will have appeared thus far: First, write out the first 26 digits of pi: This code was evidentally created when I believed in the idea of security through obscurity, and also when I knew next to nothing about cryptography except that you could encrypt stuff and then, like, decrypt it and stuff also, public keys. I figured, the more esoteric and nonsensical, the better, so that if I ever needed to send a message to my future self I could rest assured knowing that no one except me would ever decipher it. When I was in high school and still harbouring goals of one day becoming a spy, I made up this code revolving around the first twenty-six digits of pi (which I conveniently had memorised) and the Fibonacci sequence.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |