开发者

Checking every possible alphabet cipher combination

开发者 https://www.devze.com 2023-02-16 19:04 出处:网络
I\'ve got what I think is a cipher (this isn\'t homework, just a challenge I thought I\'d try to solve via coding for fun) which is:

I've got what I think is a cipher (this isn't homework, just a challenge I thought I'd try to solve via coding for fun) which is:

"uiw uiw n la ltid mtel teacyihr n heeig sfsst"

To try to solve it, I'd like to iterate over every possible combination of cipher assignments for every letter in the alphabet (in an obviously brute force fashion), but I can't figure out an elegant way of going about that. Once I get the current iteration of the cipher assignment, I figure I'll transform the cipher text according to the cipher and then compare the first 3-letter word to a 3-letter wordlist and the last two words to a five letter wordlist, 开发者_如何学编程and if all three check out as being actual words, I'll have it print the results to file. This should give me a list of reasonable starting points to be able to weed out the incorrect results. If anyone has any ideas on how to go about implementing the iterative cipher I'd greatly appreciate it. Many thanks,

Peabody


You can have 26 for loop.

OK. I am kidding.


An obvious but inefficient version in pseudo code:

for i = 0 - 26^26-1
  /* a = i/26^25 % 26
     ...
     z = i/26^0 % 26 */
  if all deciphered words are in the word list
    print
  end if
end for

By the way, I do not think it is the right way to decipher as said in your question, because I cannot find an example of double presence of a same word in an English sentence.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号