Created
January 29, 2016 08:33
-
-
Save niorad/2e55e719befcf2cd711b to your computer and use it in GitHub Desktop.
Cesar-Cipher in Haskell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CesarCipher where | |
import Data.Char | |
wrapMin = 97 | |
wrapMax = 122 | |
shifty x | |
| x > wrapMax = x - wrapMax + wrapMin | |
| otherwise = x | |
encrypt :: Int -> String -> String | |
encrypt shift message = map chr $ map shifty $ map (+shift) (map ord message) | |
decrypt :: Int -> String -> String | |
decrypt shift message = map chr $ map ((shift)-) (map ord message) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment