strkey

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidVersionByte = fmt.Errorf("invalid version byte")

ErrInvalidVersionByte is returned when the version byte from a provided strkey-encoded string is not one of the valid values.

Functions

func Decode

func Decode(expected VersionByte, src string) ([]byte, error)

Decode decodes the provided StrKey into a raw value, checking the checksum and ensuring the expected VersionByte (the version parameter) is the value actually encoded into the provided src string.

func Encode

func Encode(version VersionByte, src []byte) (string, error)

Encode encodes the provided data to a StrKey, using the provided version byte.

func MustDecode

func MustDecode(expected VersionByte, src string) []byte

MustDecode is like Decode, but panics on error

func MustEncode

func MustEncode(version VersionByte, src []byte) string

MustEncode is like Encode, but panics on error

Types

type VersionByte

type VersionByte byte

VersionByte represents one of the possible prefix values for a StrKey base string--the string the when encoded using base58 yields a final StrKey.

const (
	AccountAddressVersionByte VersionByte = 0x5b // Base58-encodes to 'A...'
	AccountSeedVersionByte    VersionByte = 0xff // Base58-encodes to 'S...'
	DeviceSeedVersionByte     VersionByte = 0x7d // Base58-encodes to 'D...'
	NetworkAddressVersionByte VersionByte = 0xd3 // Base58-encodes to `N...`
)

func Version

func Version(src string) (VersionByte, error)

Version extracts and returns the version byte from the provided source string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL