A BIP-0173 implementation of bech32 text encoding and decoding.
elm install elm-cardano/bech32
-- Generally, one would simply deal with Elm's `Bytes` directly.
words : List Int
words =
[ 122, 193, 158, 105, 175, 136, 116, 57, 247, 224, 251, 27, 11, 236
, 48, 252, 141, 208, 43, 15, 115, 180, 209, 244, 26, 54, 207, 244
]
case Bech32.encode { prefix = "pool", data = words8ToBytes words } of
Ok result ->
result |> Expect.equal "pool10tqeu6d03p6rnalqlvdshmpsljxaq2c0ww6draq6xm8lgyl2a3p"
Err failure ->
Debug.toString failure |> Expect.fail
case Bech32.decode "pool10tqeu6d03p6rnalqlvdshmpsljxaq2c0ww6draq6xm8lgyl2a3p" of
Ok result ->
Expect.all
[ \subject -> subject.prefix |> Expect.equal "pool"
, \subject -> bytesToWords8 subject.data |> Expect.equal words
]
result
Err failure ->
Debug.toString failure |> Expect.fail
See CHANGELOG.md