From: Neil Smith Date: Wed, 4 Jun 2014 19:12:10 +0000 (+0100) Subject: Tidied up keyword ciphers and writeups X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=7289edeaa9e6601bce43b8bd6c1ef7c3d47cf32a;p=cipher-training.git Tidied up keyword ciphers and writeups --- diff --git a/cipher.py b/cipher.py index ba62d41..e39abce 100644 --- a/cipher.py +++ b/cipher.py @@ -242,9 +242,9 @@ def affine_decipher(message, multiplier=1, adder=0, one_based=True): class Keyword_wrap_alphabet(Enum): - from_a = 0 - from_last = 1 - from_largest = 2 + from_a = 1 + from_last = 2 + from_largest = 3 def keyword_cipher_alphabet_of(keyword, wrap_alphabet=Keyword_wrap_alphabet.from_a): diff --git a/cipherbreak.py b/cipherbreak.py index 0d3fd78..2a70cee 100644 --- a/cipherbreak.py +++ b/cipherbreak.py @@ -133,7 +133,7 @@ def keyword_break(message, wordlist=keywords, fitness=Pletters): >>> keyword_break(keyword_encipher('this is a test message for the ' \ 'keyword decipherment', 'elephant', Keyword_wrap_alphabet.from_last), \ wordlist=['cat', 'elephant', 'kangaroo']) # doctest: +ELLIPSIS - (('elephant', ), -52.834575011...) + (('elephant', ), -52.834575011...) """ best_keyword = '' best_wrap_alphabet = True @@ -164,7 +164,7 @@ def keyword_break_mp(message, wordlist=keywords, fitness=Pletters, chunksize=500 >>> keyword_break_mp(keyword_encipher('this is a test message for the ' \ 'keyword decipherment', 'elephant', Keyword_wrap_alphabet.from_last), \ wordlist=['cat', 'elephant', 'kangaroo']) # doctest: +ELLIPSIS - (('elephant', ), -52.834575011...) + (('elephant', ), -52.834575011...) """ with Pool() as pool: helper_args = [(message, word, wrap, fitness) diff --git a/slides/keyword-break.html b/slides/keyword-break.html index 46dded5..4a2772c 100644 --- a/slides/keyword-break.html +++ b/slides/keyword-break.html @@ -1,7 +1,7 @@ - Affine ciphers + Breaking keyword ciphers