Documentation
¶
Overview ¶
Package encoding provides encoding and decoding of different formats like Base62, Saltpack, BIP39.
Index ¶
- func BreakString(msg string, wordLen int, lineLen int) string
- func BytesToPhrase(b []byte) (string, error)
- func Decode(s string, encoding Encoding) ([]byte, error)
- func DecodeSaltpack(msg string, isHTML bool) ([]byte, string, error)
- func Encode(b []byte, encoding Encoding) (string, error)
- func EncodeSaltpack(b []byte, brand string) string
- func FindSaltpack(msg string, isHTML bool) (string, string)
- func HasUpper(s string) bool
- func IsASCII(b []byte) bool
- func IsAlphaNumeric(s string, extra string) bool
- func IsValidPhrase(phrase string, sanitize bool) bool
- func MustDecode(s string, encoding Encoding) []byte
- func MustEncode(b []byte, encoding Encoding) string
- func MustHex(s string) []byte
- func PhraseToBytes(phrase string, sanitize bool) (*[32]byte, error)
- func TrimSaltpack(msg string, allowSpace bool) string
- type Encoding
- type ErrInvalidPhrase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BreakString ¶
BreakString breaks words and lines.
func BytesToPhrase ¶
BytesToPhrase returns a phrase for bytes
func DecodeSaltpack ¶
DecodeSaltpack decodes saltpack message.
func EncodeSaltpack ¶
EncodeSaltpack encodes bytes to saltpack message.
func FindSaltpack ¶
FindSaltpack finds saltpack message in a string.
func IsAlphaNumeric ¶
IsAlphaNumeric returns true if string is only a-z, A-Z, 0-9 with optional extra characters.
func IsValidPhrase ¶
IsValidPhrase checks is phrase is valid
func MustEncode ¶
MustEncode returns encoding or panics on error.
func PhraseToBytes ¶
PhraseToBytes decodes a bip39 mnemonic into bytes
func TrimSaltpack ¶
TrimSaltpack removes non base63 characters from a string.
Types ¶
type Encoding ¶
type Encoding string
Encoding is an encoding for bytes to and from a string
const ( // NoEncoding ... NoEncoding Encoding = "" // Hex (Base16) encoding Hex Encoding = "base16" // Base32 encoding Base32 Encoding = "base32" // Base58 encoding Base58 Encoding = "base58" // Base62 encoding Base62 Encoding = "base62" // Base64 encoding (with padding) Base64 Encoding = "base64" // Saltpack encoding Saltpack Encoding = "saltpack" // BIP39 encoding BIP39 Encoding = "bip39" )
func NewEncoding ¶
NewEncoding returns an Encoding from a string.
type ErrInvalidPhrase ¶
type ErrInvalidPhrase struct {
// contains filtered or unexported fields
}
ErrInvalidPhrase if phrase is invalid.
func (ErrInvalidPhrase) Error ¶
func (e ErrInvalidPhrase) Error() string