#### Archived

This topic is now archived and is closed to further replies.

# Substitution Cipher

This topic is 5371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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)

##### Share on other sites
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.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 13
• 14
• 9
• ### Forum Statistics

• Total Topics
633366
• Total Posts
3011527
• ### Who's Online (See full list)

There are no registered users currently online

×