X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=szyfrow%2Fcaesar.py;h=fbfe05086ec85e492f07ef5b4b1d665d0c75a55c;hb=27c8005f6dea0026887b80a01b5f93a8f1b3c2b2;hp=ec878fcf2fe941d029853d0bed103e9250925054;hpb=a870050db6bc974b1bb0d132001750b6624fb43f;p=szyfrow.git diff --git a/szyfrow/caesar.py b/szyfrow/caesar.py index ec878fc..fbfe050 100644 --- 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 @@ -109,13 +107,9 @@ def caesar_break(message, fitness=Pletters): 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 - 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