Documentation
ยถ
Overview ยถ
Package radix implements radix conversions for integer sequences ([]byte or []int) and their encoding/deconding to string by specified alphabet.
Example ยถ
out, err := radix.Convert([]int{1, 3, 3, 7}, 10, 16) if err != nil { log.Fatal(err) } str, err := radix.Encode(out, "0123456789ABCDEF") if err != nil { log.Fatal(err) } fmt.Println(str)
Output: 539
Example (Bitcoin) ยถ
addr := []byte{138, 238, 64, 184, 232, 126, 176, 91, 195, 185, 255, 144, 35, 73, 187, 45, 209, 154, 94, 144} str, err := radix.Base58Encode(addr, radix.AlphabetBitcoin) if err != nil { log.Fatal(err) } fmt.Println(str)
Output: 2wG9ewuHafzR4yG2hYu8U3YmpZxb
Example (Emoji) ยถ
out, err := radix.Convert([]int{1, 3, 3, 7}, 10, 5) if err != nil { log.Fatal(err) } str, err := radix.Encode(out, "๐๐๐๐๐") if err != nil { log.Fatal(err) } fmt.Println(str)
Output: ๐๐๐๐๐
Index ยถ
- Constants
- Variables
- func Base58Decode(input string, alphabet string) ([]byte, error)
- func Base58Encode(input []byte, alphabet string) (string, error)
- func Convert(in []int, inrx int, outrx int) (out []int, err error)
- func ConvertBytes(in []byte, outrx int) (out []byte, err error)
- func Decode(input string, alphabet string) (output []int, err error)
- func DecodeBytes(input string, alphabet string) (output []byte, err error)
- func Encode(input []int, alphabet string) (output string, err error)
- func EncodeBytes(input []byte, alphabet string) (output string, err error)
Examples ยถ
Constants ยถ
View Source
const AlphabetBitcoin = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
View Source
const AlphabetFlickr = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
View Source
const AlphabetRipple = "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"
Variables ยถ
View Source
var ErrBase58BadAlphabet = errors.New("base58: alphabet length less than 58")
Functions ยถ
func Convert ยถ
Convert converts input (int) with radix (inrx) to ouput (out) with radix (outrx).
Example ยถ
out, err := radix.Convert([]int{1, 3, 3, 7}, 10, 2) if err != nil { log.Fatal(err) } fmt.Println(out)
Output: [1 0 1 0 0 1 1 1 0 0 1]
func ConvertBytes ยถ
ConvertBytes converts input bytes (in) with 256 radix to output bytes (out) with radix (outrx).
func DecodeBytes ยถ
DecodeBytes decodes input string by alphabet to bytes output.
Types ยถ
This section is empty.
Click to show internal directories.
Click to hide internal directories.