11.07.2015 Views

Cryptography - Sage

Cryptography - Sage

Cryptography - Sage

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Solution.below.The coincidence index for each of the ciphertext samples is given in the table1. 0.04387225548902192. 0.06570233203879853. 0.04472396925227114. 0.06295453108202115. 0.04128012438455556. 0.06552250683626457. 0.04123391156371738. 0.06749180610660689. 0.068557348267662210. 0.065734175809402411. 0.0665847779993272All but ciphertexts 1, 3, 5 and 7 are consistent with output from a simple substitution ortransposition cipher. It is likely that the exceptional ones employ a polyalphabetic cipher.In order to distinguish substitution and transposition ciphers, it is necessary to look atcharacter distributions, e.g. a close match with the frequency distribution of English (or amodern language) suggests a transposition cipher.Exercise 3.3 For each of the cryptographic texts from the course web page, for variousperiods extract the substrings of im + j-th characters. For those which are not simplesubstitutions, can you identify a period?Solution. Using the average coincidence index of the ciphertext decimations, we find thatthe periods of the ciphertexts 1, 3, 5, and 7 are 11, 6, 14, and 9, respectively. The code toverify this is:sage: ct05 = strip_encoding(open("Ciphertext/cipher05.txt").read())sage: n = len(ct05)sage: for m in range(1,10):cis = [ ct05[i:n:m].coincidence_index() for i in range(m) ]print "%s : %s" % (m, sum(cis)/m)with output:106 Appendix C. Solutions to Exercises

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!