-- | Cryptography utilities. module Puppy.Crypto (sha256, base64) where import Crypto.Hash (Digest, SHA256, hash) import Data.ByteString.Base64 (encodeBase64') import qualified Data.ByteArray as BA import qualified Data.ByteString as BS class Base64 x where -- | Base64-encode something base64 :: x -> x instance Base64 BS.ByteString where base64 = encodeBase64' -- | Hash a ByteString with SHA-256 sha256 :: BS.ByteString -> BS.ByteString sha256 = BA.pack . BA.unpack . (hash :: BS.ByteString -> Digest SHA256)