Substitution Cipher

Started by
1 comment, last by InfinitySquared 20 years, 1 month ago
I am trying to code a program that will take any legitimate cipher and decrypt it using either a rotational or a substitution based method. I was able to get the rotational part working using the Chi-Square statistic, but I''m completely stumped on using substitution. The only thing I have access to is a dictionary. Can someone give me some general ideas on program logic I should use? Just randomly guessing combinations and comparing to dictionary entries seems really inefficient as the program has to complete the decryption in 30 seconds or less. Thanks in advance.
Advertisement
If you know its just a simple mapping from character to character, one thing you could do is use character statistics to assist. For example, ''e'' is the most common letter in english writing, so you could presume the most common character in the cipher text is E. If you had your program first analize several texts (or did so and hard coded the table when making the program), you could know which characters are probably what and use that as a starting point. Once you have a few letters (even just ''e'' and space), you can start trying to find words. The ''potential words'' you find (using pattern matching, treating unknown characters as a ''match any single character'' wildcard) can further assist you in figuring out which letters transform into what.

Of course, that all assumes the plain text will be regular english text and not something specially designed to be hard to decrypt (which it could be since it sounds like this is for a contest)
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
It sounds like you need to gather some frequency statistics from your dictionary first. I wont say a single word more as this sounds like an assignment.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

This topic is closed to new replies.

Advertisement