Bech32 encode
bech32-encode · version 1.0.0 · Encoding & checksums · free, no key needed
Encode lowercase HRP and 5-bit data as Bech32 or Bech32m text using that checksum.
Use when you need to: encode lowercase hrp and five-bit symbols as bech32 · bech32m checksum text from an hrp and symbol list · create bech32 text with checksum constant one.
Decide before calling
Read the versioned contract and the supported scope below. Reuse bech32-encode@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use bech32-encode@1.0.0 for encode lowercase hrp and five-bit symbols as bech32. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- encode lowercase hrp and five-bit symbols as bech32
- bech32m checksum text from an hrp and symbol list
- create bech32 text with checksum constant one
- create bech32m text with checksum constant 2bc830a3
- attach a six character bech32 checksum
- hrp and data symbols to lowercase bech32
- bech32 encode an empty data part
- build a bech32m string from values 0 to 31
Not supported
- decode a bech32 string back into symbols
- choose bech32 or bech32m from a witness version
- correct a damaged checksum
- encode bytes with RFC 4648 base32
Behavior
- HRP is 1 to 83 characters, each ASCII 33-126, and must already be lowercase. A-Z is rejected. The encoder does not case-fold.
- data is 5-bit integers 0 through 31. There is no default variant: pass bech32 (checksum constant 1, BIP 173) or bech32m (checksum constant 0x2bc830a3, BIP 350).
- Output text is lowercase HRP, separator 1, data characters, and a 6-character checksum. The same HRP and data produce different checksums for the two variants.
- The encoded character count is HRP length + data length + 7 and must be at most 90. A longer combination is limit_exceeded before symbols are scanned.
- This is a generic codec. It does not apply segwit witness-version policy, program-length rules, or error correction.
- Disclaimer: format transform only; provides no confidentiality, integrity, or authenticity.
Input
hrp(string, required): min length 1; max length 83; pattern^[\x21-\x40\x5b-\x7e]+$data(array of integer, required): max items 82; each min 0; each max 31variant(one of "bech32", "bech32m", required)
Output
text(string, required): min length 8; max length 90; pattern^[\x21-\x40\x5b-\x7e]+$variant(one of "bech32", "bech32m", required)checksum(string, required): min length 6; max length 6; pattern^[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{6}$
Limits
- max hrp chars: 83
- max data items: 82
- max character count: 90
Example
Request input:
{
"hrp": "a",
"data": [],
"variant": "bech32"
}
Response:
{
"result": {
"text": "a12uel5l",
"variant": "bech32",
"checksum": "2uel5l"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "bech32-encode",
"version": "1.0.0",
"input": {
"hrp": "a",
"data": [],
"variant": "bech32"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/bech32-encode/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"hrp":"a","data":[],"variant":"bech32"}'
The machine-readable contract is at /v1/tools/bech32-encode/versions/1.0.0.
CLI
node cli.mjs run bech32-encode 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Bech32 decode: Decode Bech32 or Bech32m text into a lowercase HRP, 5-bit data, and the checksum variant.
- Bech32 validate: Check Bech32 or Bech32m text and return a reason, without throwing when the checksum fails.
- Bech32 convert bits: Regroup integers between bit widths using BIP 173 rules, rejecting bad leftover padding.
- Segwit address encode: Encode a witness program as a native segwit address using Bech32 for v0 and Bech32m for v1-v16.
- Pem envelope format: Format a label and lowercase hex bytes as a canonical RFC 7468 PEM envelope.
- Pem envelope parse: Parse one RFC 7468 textual envelope into its label and lowercase hex bytes.