Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

base58 source realm

Package base58 ports the core of Bitcoin's Base58 codec (à la mr-tron/base58 and btcutil/base58) to a gno.land realm.

Overview

Package base58 ports the core of Bitcoin's Base58 codec (à la mr-tron/base58 and btcutil/base58) to a gno.land realm.

Base58 is a base conversion from base-256 (raw bytes) to base-58 using an alphabet that omits the visually ambiguous characters 0 (zero), O (capital o), I (capital i) and l (lower L). The conversion here is done with pure byte-slice math — the classic div/mod-by-58 carry loop — so it needs no math/big. Leading zero bytes map to leading '1' characters and back, exactly like the reference implementations.

Constants 1

const Alphabet

1const Alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
source

Alphabet is the Bitcoin Base58 alphabet.

Functions 4

func Decode

Action
1func Decode(s string) []byte
source

Decode converts a Base58 string back to the original byte slice. It returns nil if the string contains a character outside the alphabet.

Algorithm: the mirror of Encode — treat the string as a big base-58 integer and convert it back to base-256 bytes with a carry loop. Each leading '1' becomes a leading zero byte.

func Encode

Action
1func Encode(input []byte) string
source

Encode converts a byte slice to its Base58 string representation.

Algorithm: treat the input as a big base-256 integer and repeatedly convert it into base-58 digits via a carry loop, most-significant digit first. Each leading zero byte becomes a leading '1'.

func IsValid

Action
1func IsValid(s string) bool
source

IsValid reports whether every character of s belongs to the Base58 alphabet.

func Render

1func Render(path string) string
source

Render produces the gnoweb Markdown view.

  • "/" → the alphabet + a small gallery of worked examples.
  • "/<hex>" → decode the hex input to bytes, show its Base58, and the hex-encoded decoded round-trip to prove Encode/Decode are inverse.

Imports 2

  • encoding/hex stdlib
  • strings stdlib

Source Files 2