#!/usr/bin/runghc import AffineCipher import Data.HashSet (HashSet) import Data.List import DetectEnglish affineHacker :: HashSet String -> Float -> String -> [((Int, Int), String)] affineHacker wordList threshold message = [ ((keyA, keyB), decryptString keyA keyB message) | keyA <- [2 .. m], gcd keyA m == 1, keyB <- [1 .. m], isEnglish wordList threshold (decryptString keyA keyB message) ] main :: IO () main = do let message = "A computer would deserve to be called intelligent if it could deceive a human into believing that it was human. -Alan Turing" let keyA = 43 let keyB = 56 putStrLn "Your encrypted message is:" putStrLn (encryptString keyA keyB message) hashDict <- importDictionary putStrLn "Your cracked ciphertext is:" print (affineHacker hashDict 0.2 (encryptString keyA keyB message))