Skip to content

Commit

Permalink
Merge pull request #91 from parsonsmatt/matt/ghc94
Browse files Browse the repository at this point in the history
Support base64 >= 0.5
  • Loading branch information
qnikst authored Jan 5, 2023
2 parents b21bc80 + e2c491e commit 88f3972
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion HaskellNet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Library
Network.Mail.Mime

Build-Depends:
base >= 4.3 && < 4.17,
base >= 4.3 && < 4.18,
network >= 2.6.3.1 && < 3.2,
mtl,
bytestring >=0.10.2,
Expand Down
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
.
24 changes: 22 additions & 2 deletions src/Network/HaskellNet/Auth.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{-# language CPP #-}

module Network.HaskellNet.Auth
where

import Crypto.Hash.MD5
import Data.Text.Encoding.Base64 as B64

#if MIN_VERSION_base64(0,5,0)
import Data.Base64.Types as B64
#endif

import Data.Word
import Data.List
import Data.Bits
Expand All @@ -28,10 +34,24 @@ instance Show AuthType where
showMain CRAM_MD5 = "CRAM-MD5"

b64Encode :: String -> String
b64Encode = T.unpack . B64.encodeBase64 . T.pack
b64Encode = T.unpack . encode . T.pack
where encode =
#if MIN_VERSION_base64(0,5,0)
B64.extractBase64 . B64.encodeBase64
#else
B64.encodeBase64
#endif



b64Decode :: String -> String
b64Decode = T.unpack . B64.decodeBase64Lenient . T.pack
b64Decode = T.unpack . decode . T.pack
where decode =
#if MIN_VERSION_base64(0,5,0)
B64.decodeBase64Lenient . B64.assertBase64
#else
B64.decodeBase64Lenient
#endif

showOctet :: [Word8] -> String
showOctet = concatMap hexChars
Expand Down

0 comments on commit 88f3972

Please sign in to comment.