diff options
author | Joey Hess <joey@kitenet.net> | 2011-05-01 14:27:40 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-05-01 14:27:40 -0400 |
commit | 2ddade8132169ea751628f72ae5b03c5921abafc (patch) | |
tree | 35e4eaf5b70577e2b13e3e1f42a5ba6ed5c5c9a1 /Base64.hs | |
parent | 3095e1631180d87cba112c210dfdfeee9b57ef54 (diff) |
factor out base64 code
Diffstat (limited to 'Base64.hs')
-rw-r--r-- | Base64.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Base64.hs b/Base64.hs new file mode 100644 index 000000000..cc6346b41 --- /dev/null +++ b/Base64.hs @@ -0,0 +1,20 @@ +{- Simple Base64 access + - + - Copyright 2011 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Base64 (toB64, fromB64) where + +import Codec.Binary.Base64 +import Data.Bits.Utils + +toB64 :: String -> String +toB64 = encode . s2w8 + +fromB64 :: String -> String +fromB64 s = + case decode s of + Nothing -> error "bad base64 encoded data" + Just ws -> w82s ws |