projects
/
szyfrow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Testing done for now.
[szyfrow.git]
/
szyfrow
/
caesar.py
diff --git
a/szyfrow/caesar.py
b/szyfrow/caesar.py
index ec878fcf2fe941d029853d0bed103e9250925054..fbfe05086ec85e492f07ef5b4b1d665d0c75a55c 100644
(file)
--- a/
szyfrow/caesar.py
+++ b/
szyfrow/caesar.py
@@
-1,7
+1,5
@@
-from support.utilities import *
-from support.language_models import *
-
-from logger import logger
+from szyfrow.support.utilities import *
+from szyfrow.support.language_models import *
def caesar_encipher_letter(accented_letter, shift):
"""Encipher a letter, given a shift amount
def caesar_encipher_letter(accented_letter, shift):
"""Encipher a letter, given a shift amount
@@
-109,13
+107,9
@@
def caesar_break(message, fitness=Pletters):
for shift in range(26):
plaintext = caesar_decipher(sanitised_message, shift)
fit = fitness(plaintext)
for shift in range(26):
plaintext = caesar_decipher(sanitised_message, shift)
fit = fitness(plaintext)
- logger.debug('Caesar break attempt using key {0} gives fit of {1} '
- 'and decrypt starting: {2}'.format(shift, fit,
- plaintext[:50]))
+
if fit > best_fit:
best_fit = fit
best_shift = shift
if fit > best_fit:
best_fit = fit
best_shift = shift
- logger.info('Caesar break best fit: key {0} gives fit of {1} and '
- 'decrypt starting: {2}'.format(best_shift, best_fit,
- caesar_decipher(sanitised_message, best_shift)[:50]))
+
return best_shift, best_fit
return best_shift, best_fit