From f966519df0657b57d74df3d0add18b148a032023 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 2 Jun 2016 03:06:05 +0200 Subject: hex is stable across case fold --- ymir/mlmmj-expose.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ymir/mlmmj-expose.nix b/ymir/mlmmj-expose.nix index b19b08f2..ad015f4e 100644 --- a/ymir/mlmmj-expose.nix +++ b/ymir/mlmmj-expose.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: let - haskellEnv = pkgs.haskellPackages.ghcWithPackages (pkgs: with pkgs; [ filepath directory SimpleAES bytestring base64-bytestring ]); + haskellEnv = pkgs.haskellPackages.ghcWithPackages (pkgs: with pkgs; [ filepath directory SimpleAES bytestring hex ]); mlmmj-exposed = pkgs.stdenv.mkDerivation { name = "mlmmj-exposed"; src = pkgs.writeText "mlmmj-exposed.hs" '' @@ -26,7 +26,7 @@ let import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as CBS - import qualified Data.ByteString.Base64 as Base64 + import Data.Hex main :: IO () main = do @@ -34,9 +34,9 @@ let case progName of "mlmmj-exposed" -> do args <- getArgs - hPutStrLn stderr $ show args case args of - [listDir, (LBS.fromStrict . Base64.decodeLenient . unmassage . CBS.pack -> extension)] -> do + [listDir, rawExtension] -> do + extension <- LCBS.pack <$> unhex rawExtension setCurrentDirectory listDir key <- (BS.readFile "exposed.key") `catchIOError` (\e -> if isDoesNotExistError e then randomKey >>= (\k -> BS.writeFile "exposed.key" k >> return k) else ioError e) let ((map toLower -> ident), (map toLower -> recipient)) = read . CLBS.unpack $ decryptMsg CBC key extension @@ -68,7 +68,7 @@ let subscribers <- getSubscribers forM_ recipients (\recipient -> do { unless (recipient `elem` subscribers) . die $ "Unknown recipient: ‘" ++ recipient ++ "’"; - encryptMsg CBC key (CLBS.pack . show $ (ident, recipient)) >>= putStrLn . (\ext -> takeFileName listDir ++ "+" ++ ext ++ "@subs.lists.yggdrasil.li") . CBS.unpack . massage . Base64.encode . LBS.toStrict; + encryptMsg CBC key (CLBS.pack . show $ (ident, recipient)) >>= putStrLn . (\ext -> takeFileName listDir ++ "+" ++ ext ++ "@subs.lists.yggdrasil.li") . hex . LCBS.unpack; }) _ -> hPutStrLn stderr ("Called without expected arguments ( [ [...]])") >> exitWith (ExitFailure 2) _ -> hPutStrLn stderr ("Called under unsupported name ‘" ++ progName ++ "’") >> exitWith (ExitFailure 2) -- cgit v1.2.3