.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
main = do arguments <- getArgs
          exists <- doesFileExist . head $ arguments
          if arguments == []
             then
                 putStrLn "Usage:\n./xor-break [FILE]"
             else
                 if not exists
                    then
                        putStrLn $ "File " ++ file ++ " doesn't exist."
                    else
                        contents <- readFile . head $ arguments
                        let keyLength = getKeyLength contents
                            splitData = getEvery keyLength contents
                            key = getKeys splitData
                            decrypted = decrypt key contents
                            file = head arguments 
                        print decrypted