Skip to content

Instantly share code, notes, and snippets.

@ehamberg
Created October 28, 2011 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehamberg/1322212 to your computer and use it in GitHub Desktop.
Save ehamberg/1322212 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment