utils

package
v1.1.28 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package blake256 implements BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate).

Index

Constants

View Source
const (
	StdPadding rune = '=' // Standard padding character
	NoPadding  rune = -1  // No padding
)
View Source
const BlockSize = 64

The block size of the hash algorithm in bytes.

View Source
const Size = 32

The size of BLAKE-256 hash in bytes.

View Source
const Size224 = 28

The size of BLAKE-224 hash in bytes.

Variables

View Source
var (
	ErrorInvalidAddress = errors.New("Invalid address!")
	/*
	 This table corresponding to the first 128 chars in ascii table.If the char is not one of
	 "qpzry9x8gf2tvdw0s3jn54khce6mua7l" which is the code table of base32(Only consists
	 of alphanumeric characters excluding "1", "b", "i", and "o"), -1 will be set in
	 the corresponding position.Otherwise, the sequence number of alphanumeric character
	 will be set. For example, '0'is the 48th(from 0 starts) char in ascii table and the 15th
	 (from 0 starts)letter in code table, then 15 will be set in the 48th position.
	*/
	CHARSET_REV = []int8{}/* 128 elements not displayed */

)
View Source
var (
	ErrorInvalidBase58String = errors.New("invalid base58 string")
)

Errors

Functions

func Base58Decode

func Base58Decode(input string, alphabetStr string) ([]byte, error)

Decode docode with custom Alphabet

func Base58Encode

func Base58Encode(input []byte, alphabetStr string) string

Encode encode with custom Alphabet

func Bech32Decode

func Bech32Decode(address, alphabet string) ([]byte, error)

func Bech32Encode

func Bech32Encode(prefix, alphabet string, payload []byte, payloadPrefix []byte) string

func DoubleBlake256

func DoubleBlake256(data []byte) []byte

func IsLowerHex

func IsLowerHex(data string) bool

func New

func New() hash.Hash

New returns a new hash.Hash computing the BLAKE-256 checksum.

func New224

func New224() hash.Hash

New224 returns a new hash.Hash computing the BLAKE-224 checksum.

func New224Salt

func New224Salt(salt []byte) hash.Hash

New224Salt is like New224 but initializes salt with the given 16-byte slice.

func NewSalt

func NewSalt(salt []byte) hash.Hash

NewSalt is like New but initializes salt with the given 16-byte slice.

Types

type Base58Alphabet

type Base58Alphabet struct {
	// contains filtered or unexported fields
}

Alphabet The base58 Alphabet object.

func NewBase58Alphabet

func NewBase58Alphabet(alphabet string) *Base58Alphabet

NewAlphabet create a custom Alphabet from 58-length string. Note: len(rune(Alphabet)) must be 58.

type CorruptInputError

type CorruptInputError int64

func (CorruptInputError) Error

func (e CorruptInputError) Error() string

type Encoding

type Encoding struct {
	// contains filtered or unexported fields
}

func NewEncoding

func NewEncoding(encoder string) *Encoding

NewEncoding returns a new padded Encoding defined by the given Alphabet, which must be a 64-byte string that does not contain the padding character or CR / LF ('\r', '\n'). The resulting Encoding uses the default padding character ('='), which may be changed or disabled via WithPadding.

func (*Encoding) Base64Decode

func (enc *Encoding) Base64Decode(s string) ([]byte, error)

func (*Encoding) Base64Encode

func (enc *Encoding) Base64Encode(src []byte) string

func (*Encoding) Decode

func (enc *Encoding) Decode(dst, src []byte) (n int, err error)

func (*Encoding) DecodedLen

func (enc *Encoding) DecodedLen(n int) int

func (*Encoding) Encode

func (enc *Encoding) Encode(dst, src []byte)

func (*Encoding) EncodedLen

func (enc *Encoding) EncodedLen(n int) int

Jump to

Keyboard shortcuts

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