Documentation ¶
Overview ¶
Package bech32 provides a Go implementation of the bech32 format.
Bech32 strings consist of a prefix, followed by the separator :, then a checksummed data part encoded using the 32 characters "qpzry9x8gf2tvdw0s3jn54khce6mua7l".
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode decodes a string that was encoded with Encode.
Example ¶
This example demonstrates how to decode a bech32 encoded string.
package main import ( "encoding/hex" "fmt" "github.com/catspa3/catspad/util/bech32" ) func main() { encoded := "customprefix!:::::q:ppzxzarpyp6x7grzv5sx2mnrdajx2epqd9h8gmeqgfjkx6pnxgc3swlew4" prefix, decoded, version, err := bech32.Decode(encoded) if err != nil { fmt.Println("Error:", err) } // Show the decoded data. fmt.Println("Decoded prefix:", prefix) fmt.Println("Decoded version:", version) fmt.Println("Decoded Data:", hex.EncodeToString(decoded)) }
Output: Decoded prefix: customprefix!:::::q Decoded version: 8 Decoded Data: 4461746120746f20626520656e636f64656420696e746f20426563683332
func Encode ¶
Encode prepends the version byte, converts to uint5, and encodes to Bech32.
Example ¶
This example demonstrates how to encode data into a bech32 string.
package main import ( "fmt" "github.com/catspa3/catspad/util/bech32" ) func main() { data := []byte("Data to be encoded into Bech32") encoded := bech32.Encode("customprefix!:::::q", data, 8) // Show the encoded data. fmt.Println("Encoded Data:", encoded) }
Output: Encoded Data: customprefix!:::::q:ppzxzarpyp6x7grzv5sx2mnrdajx2epqd9h8gmeqgfjkx6pnxgc3swlew4
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.