Created
June 23, 2016 08:57
-
-
Save antekone/405cef8c44af3b5aea6e59d9b9be43da to your computer and use it in GitHub Desktop.
This file contains 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
import qualified Data.ByteString.Lazy as BL | |
import Data.Binary.Get | |
import Data.Word | |
import Data.Bits | |
import Data.Char | |
readArray :: Get [Word8] | |
readArray = do | |
empty <- isEmpty | |
if empty | |
then return [] | |
else do | |
byte <- getWord8 | |
rest <- readArray | |
return (byte : rest) | |
decodeCharonCache :: Int -> [Int] -> [Int] | |
decodeCharonCache i [] = [] | |
decodeCharonCache i (x:xs) = | |
[xorVal `xor` x `xor` 0x6A] ++ decodeCharonCache (i + 1) xs | |
where | |
xorVal = (i `div` 256) `xor` (i `mod` 256) | |
main :: IO () | |
main = do | |
input <- BL.getContents | |
putStr $ map chr $ decodeCharonCache 0 $ map (\x -> fromIntegral x :: Int) (runGet readArray input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment