2024-05-19 13:23:39 +02:00
|
|
|
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
|
2024-05-20 23:28:14 +02:00
|
|
|
|
2024-05-19 13:23:39 +02:00
|
|
|
import qualified Data.Text as T
|
|
|
|
import qualified Data.Text.Encoding as T
|
2024-05-20 23:28:14 +02:00
|
|
|
-- import qualified Data.Text.IO as T
|
2024-05-19 13:23:39 +02:00
|
|
|
|
|
|
|
dec58 :: String -> String
|
|
|
|
dec58 input =
|
2024-05-20 23:28:14 +02:00
|
|
|
case B58.decodeBase58 (T.pack input) of
|
|
|
|
Just decodedStr -> T.unpack (T.decodeUtf8 decodedStr)
|
|
|
|
Nothing -> "Error decoding Base58.\n"
|
2024-05-19 13:23:39 +02:00
|
|
|
|
|
|
|
enc58 :: String -> String
|
|
|
|
enc58 = T.unpack . B58.encodeBase58 . BSU.fromString
|