git-annex/Utility/Base64.hs

19 lines
393 B
Haskell
Raw Normal View History

2011-05-01 18:27:40 +00:00
{- Simple Base64 access
-
- Copyright 2011 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
2011-07-06 00:24:10 +00:00
module Utility.Base64 (toB64, fromB64) where
2011-05-01 18:27:40 +00:00
import Codec.Binary.Base64
import Data.Bits.Utils
toB64 :: String -> String
toB64 = encode . s2w8
fromB64 :: String -> String
2011-05-15 06:49:43 +00:00
fromB64 s = maybe bad w82s $ decode s
2012-12-13 04:24:19 +00:00
where bad = error "bad base64 encoded data"