Documentation ¶
Overview ¶
Example (Basic) ¶
This Example shows the basic usage of the package: Encode, Decode
// use bitcoin alphabet, just same as: base58.NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") myAlphabet := BitcoinAlphabet // encode input := []byte{0, 0, 0, 1, 2, 3} encodedString := Encode(input, myAlphabet) fmt.Printf("base58encode(%v) = %s\n", input, encodedString) // decode decodedBytes, err := Decode(encodedString, myAlphabet) if err != nil { // error occurred when encodedString contains character not in alphabet log.Fatal("base58Decode error:", err) } else { fmt.Printf("base58decode(%s) = %v\n", encodedString, decodedBytes) }
Output: base58encode([0 0 0 1 2 3]) = 111Ldp base58decode(111Ldp) = [0 0 0 1 2 3]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BitcoinAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") IPFSAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") FlickrAlphabet = NewAlphabet("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ") RippleAlphabet = NewAlphabet("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz") )
Alphabet: copy from https://en.wikipedia.org/wiki/Base58
View Source
var (
ErrorInvalidBase58String = errors.New("invalid base58 string")
)
Errors
Functions ¶
Types ¶
type Alphabet ¶
type Alphabet struct {
// contains filtered or unexported fields
}
Alphabet The base58 alphabet object.
func NewAlphabet ¶
NewAlphabet create a custom alphabet from 58-length string. Note: len(rune(alphabet)) must be 58.
Click to show internal directories.
Click to hide internal directories.