#base32 #encoding #bech32


Encodes and decodes the Bech32 format

1 unstable release

0.7.3 Oct 12, 2020

#7 in #bech32

Download history 4/week @ 2021-02-20 5/week @ 2021-02-27 2/week @ 2021-03-06 6/week @ 2021-03-13 32/week @ 2021-03-20 36/week @ 2021-03-27 22/week @ 2021-04-03 66/week @ 2021-04-10 79/week @ 2021-04-17 145/week @ 2021-04-24 144/week @ 2021-05-01 122/week @ 2021-05-08 183/week @ 2021-05-15 183/week @ 2021-05-22 246/week @ 2021-05-29 210/week @ 2021-06-05

234 downloads per month

MIT license

632 lines

Bech32 Rust

Docs.rs badge Build Status

Rust implementation of the Bech32 encoding format described in BIP-0173. You can find some usage examples in the documentation.

Bitcoin-specific address encoding is handled by the bitcoin-bech32 crate.


Encoding and decoding of the Bech32 format

Bech32 is an encoding scheme that is easy to use for humans and efficient to encode in QR codes.

A Bech32 string consists of a human-readable part (HRP), a separator (the character '1'), and a data part. A checksum at the end of the string provides error detection to prevent mistakes when the string is written off or read out loud.

The original description in BIP-0173 has more details.


use bech32::{self, FromBase32, ToBase32};

let encoded = bech32::encode("bech32", vec![0x00, 0x01, 0x02].to_base32()).unwrap();
assert_eq!(encoded, "bech321qqqsyrhqy2a".to_string());

let (hrp, data) = bech32::decode(&encoded).unwrap();
assert_eq!(hrp, "bech32");
assert_eq!(Vec::<u8>::from_base32(&data).unwrap(), vec![0x00, 0x01, 0x02]);

No runtime deps


  • std
  • strict