based/src/Encoding/Base58.hs

22 lines
585 B
Haskell
Raw Normal View History

module Encoding.Base58
( enc58
, dec58
) where
import qualified Data.ByteString.Char8 as C
import Data.ByteString.UTF8 as BSU -- from utf8-string
import qualified Haskoin.Address.Base58 as B58
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
-- import qualified Data.Text.IO as T
dec58 :: String -> String
dec58 input =
case B58.decodeBase58 (T.pack input) of
Just decodedStr -> T.unpack (T.decodeUtf8 decodedStr)
Nothing -> "Error decoding Base58.\n"
enc58 :: String -> String
enc58 = T.unpack . B58.encodeBase58 . BSU.fromString