Crate bech32 [−] [src]
Encoding and decoding Bech32 format
Bech32 is a 5-bit (base-32) encoding scheme that produces strings that comprise a human-readable part, a separator, a data part, and a checksum. The encoding implements a BCH code that guarantees error detection of up to four characters with less than 1 in 1 billion chance of failing to detect more errors.
The Bech32 encoding was originally formulated in BIP-0173
Examples
use bech32::Bech32; let b = Bech32 { hrp: "bech32".to_string(), data: vec![0x00, 0x01, 0x02] }; let encoded = b.to_string().unwrap(); assert_eq!(encoded, "bech321qpz4nc4pe".to_string()); let c = Bech32::from_string(encoded); assert_eq!(b, c.unwrap());
Structs
Bech32 |
Grouping structure for the human-readable part and the data part of decoded Bech32 string. |
Enums
Error |
Error types for Bech32 encoding / decoding |