#!/usr/bin/runghc module TranspositionDecrypt (decryptString, numOfColumns) where import Data.List import Data.List.Split import TranspositionEncrypt -- | -- >>> numOfColumns 8 "Cenoonommstmme oo snnio. s s c " -- 4 numOfColumns = numOfRows -- | Actual dercyption function. -- >>> decryptString 4 "Cenoonommstmme oo snnio. s s c " -- "Common sense is not so common. " decryptString :: Int -> String -> String decryptString numCols = intercalate "" . transpose . chunksOf numCols . messagePad numCols main :: IO () main = do let message = "Common sense is not so common." let key = 8 putStrLn "Your encrypted message is:" putStrLn (encryptString key message) let numCols = numOfColumns key message putStrLn "Your decrypted message is:" putStrLn (decryptString numCols . encryptString key $ message)