module Cipher where import Data.Char (fromCharCode, toCharCode) import Data.String (fromCharArray, toCharArray) import Prelude caesar :: Int -> String -> String caesar key s = fromCharArray $ map shiftRight (toCharArray s) where shiftRight char = fromCharCode $ mod (ord char) 26 ord = (add key) <<< toCharCode unCaesar :: Int -> String -> String unCaesar key s = fromCharArray $ map shiftLeft (toCharArray s) where shiftLeft char = fromCharCode $ ord char ord chr = ((toCharCode chr) - (mod key 26)) + 26