public
Last active

  • Download Gist
crypt.hs
Haskell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import Data.Function (on)
import Data.Char (ord, chr)
import Data.Bits (xor)
import System (getArgs)
 
crypt :: FilePath -> String -> IO String
crypt filename key = do
text <- readFile filename
let code = map chr $ zipWith (xor `on` ord) text $ cycle key
return code
 
main = do
[filename,key] <- getArgs
encrypted <- crypt filename key
putStr encrypted

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.