aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2026-03-09 03:11:34 -0400
committerPaul Duncan <pabs@pablotron.org>2026-03-09 03:11:34 -0400
commitca1cf2b77a7493d2c7e3daec416e113691e5683c (patch)
tree5a4e0008cf119bc455dae783f9d5ce1919734f98
parente4faa8ca3d511b68960a46aa2f5460d1176ef8c9 (diff)
downloadpablotron.org-ca1cf2b77a7493d2c7e3daec416e113691e5683c.tar.xz
pablotron.org-ca1cf2b77a7493d2c7e3daec416e113691e5683c.zip
add content/posts/2026-03-08-pbech32-v0.1.0.mdHEADmain
-rw-r--r--content/posts/2026-03-08-pbech32-v0.1.0.md126
-rw-r--r--content/projects/pbech32.md7
-rw-r--r--data/projects.yaml5
3 files changed, 138 insertions, 0 deletions
diff --git a/content/posts/2026-03-08-pbech32-v0.1.0.md b/content/posts/2026-03-08-pbech32-v0.1.0.md
new file mode 100644
index 0000000..7712d2f
--- /dev/null
+++ b/content/posts/2026-03-08-pbech32-v0.1.0.md
@@ -0,0 +1,126 @@
+---
+slug: pbech32-v0.1.0
+title: "pbech32 v0.1.0"
+date: "2026-03-08T02:50:28-04:00"
+---
+I just released the first version of [pbech32][], a [Rust][] library for
+encoding and decoding [Bech32][] strings.
+
+[Bech32][] is a fast and user-friendly [base 32][] encoding format
+that includes a [namespace][] and [checksum][].
+
+### Links
+
+- [pbech32 Git repository][git repository]
+- [pbech32 package on crates.io][crates-io-pbech32]
+- [pbech32 API Documentation on docs.rs][docs-rs-pbech32]
+
+### Library Features
+
+- [Bech32 (BIP173)][bip173] and [Bech32m (BIP350)][bip350] support.
+- Idiomatic encoding and decoding via the [`Display`][display] and
+ [`FromStr`][fromstr] traits.
+- Decode arbitrarily long strings.
+- Streamed, allocation-free encoding to any [writer][].
+- No external dependencies.
+
+### Examples
+
+Decode from string:
+
+```rust
+use pbech32::Bech32;
+
+let s = "a1qypqxpq9mqr2hj"; // bech32m-encoded string
+let got: Bech32 = s.parse()?; // decode string
+
+assert_eq!(got.hrp.to_string(), "a"); // check human-readable part
+assert_eq!(got.data, vec![1, 2, 3, 4, 5]); // check data
+```
+
+Encode to string:
+
+```rust
+use pbech32::{Bech32, Hrp, Scheme};
+
+let scheme = Scheme::Bech32m; // checksum scheme
+let hrp: Hrp = "a".parse()?; // human-readable part
+let data = vec![1, 2, 3, 4, 5]; // data
+let got = Bech32 { scheme, hrp, data }.to_string(); // encode as string
+
+assert_eq!(got, "a1qypqxpq9mqr2hj"); // check result
+```
+
+Encode to a [writer][]:
+
+```rust
+use std::io::Write;
+use pbech32::{Encoder, Hrp, Scheme};
+
+let mut vec: Vec<u8> = Vec::new(); // output vector
+let hrp: Hrp = "hello".parse()?; // human readable part
+
+let mut encoder = Encoder::new(&mut vec, Scheme::Bech32m, hrp)?; // create encoder
+encoder.write_all(b"folks")?; // write data
+encoder.flush()?; // flush encoder (REQUIRED)
+
+let got = str::from_utf8(vec.as_ref())?; // convert output vector to string
+assert_eq!(got, "hello1vehkc6mn27xpct"); // check result
+```
+
+[bech32]: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
+ "Bech32 (BIP173)"
+[bech32m]: https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki
+ "Bech32m (BIP350)"
+[bip173]: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
+ "BIP173 (Bech32)"
+[bip350]: https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki
+ "BIP350 (Bech32m)"
+[ascii]: https://en.wikipedia.org/wiki/ASCII
+ "ASCII (Wikipedia)"
+[base 32]: https://en.wikipedia.org/wiki/Base32
+ "Base 32 (Wikipedia)"
+[checksum]: https://en.wikipedia.org/wiki/Checksum
+ "Checksum (Wikipedia)"
+[namespace]: https://en.wikipedia.org/wiki/Namespace
+ "Namespace (Wikipedia)"
+[bch code]: https://en.wikipedia.org/wiki/BCH_code
+ "BCH code (Wikipedia)"
+[alphabet]: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32
+ "BIP173: Specification: Bech32"
+[writer]: https://doc.rust-lang.org/std/io/trait.Write.html
+ "writer"
+[age encryption]: https://age-encryption.org/
+ "age encryption"
+[html]: https://en.wikipedia.org/wiki/HTML
+ "HyperText Markup Language"
+[rust]: https://rust-lang.org/
+ "Rust programming language."
+[git repository]: https://github.com/pablotron/pbech32
+ "pbech32 git repository"
+[pbech32]: https://github.com/pablotron/pbech32
+ "pbech32 Rust library"
+[cargo]: https://doc.rust-lang.org/cargo/
+ "Rust package manager"
+[podman]: https://podman.io/
+ "Podman container management tool"
+[docker]: https://docker.com/
+ "Docker container management tool"
+[api]: https://en.wikipedia.org/wiki/API
+ "Application Programming Interface (API)"
+[linter]: https://en.wikipedia.org/wiki/Lint_(software)
+ "Static code analysis tool to catch common mistakes"
+[crates.io]: https://crates.io/
+ "Rust package registry"
+[docs-rs-pbech32]: https://docs.rs/pbech32
+ "pbech32 API documentation on docs.rs"
+[crates-io-pbech32]: https://crates.io/crates/pbech32
+ "pbech32 on crates.io"
+[examples]: examples/
+ "pbech32 examples/ directory"
+[cargo-tarpaulin]: https://crates.io/crates/cargo-tarpaulin
+ "Tarpaulin code coverage reporting tool."
+[display]: https://doc.rust-lang.org/std/fmt/trait.Display.html
+ "std::fmt::Display trait"
+[fromstr]: https://doc.rust-lang.org/std/str/trait.FromStr.html
+ "std::str::FromStr trait"
diff --git a/content/projects/pbech32.md b/content/projects/pbech32.md
new file mode 100644
index 0000000..a6590a2
--- /dev/null
+++ b/content/projects/pbech32.md
@@ -0,0 +1,7 @@
+---
+title: "pbech32"
+slug: "pbech32"
+active: true
+repo: "https://github.com/pablotron/pbech32"
+text: "Bech32 encoding and decoding library."
+---
diff --git a/data/projects.yaml b/data/projects.yaml
index f800edd..944159e 100644
--- a/data/projects.yaml
+++ b/data/projects.yaml
@@ -21,6 +21,11 @@
repo: "https://github.com/pablotron/polycvss"
text: "Rust library to parse and score CVSS vector strings."
+- name: "pbech32"
+ slug: "pbech32"
+ repo: "https://github.com/pablotron/pbech32"
+ text: "Bech32 encoding and decoding library."
+
- name: "SHA2"
slug: "sha2"
repo: "https://github.com/pablotron/sha2"