util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: GPL-3.0, Apache-2.0 Imports: 2 Imported by: 12

Documentation

Index

Constants

View Source
const (
	HashLength    = 32
	AddressLength = 20
)

Lengths of hashes and addresses in bytes.

Variables

This section is empty.

Functions

func AddressToHex

func AddressToHex(addr types.Address) string

AddressToBytes convert address to hex string

func BytesToAddress

func BytesToAddress(b []byte) types.Address

BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.

func BytesToHash

func BytesToHash(b []byte) types.Hash

BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.

func Encode

func Encode(b []byte) string

Encode encodes b as a hex string with 0x prefix.

func FromHex

func FromHex(s string) []byte

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func HashToBytes

func HashToBytes(hash types.Hash) []byte

HashToBytes convert hash to []byte

func HashToHex

func HashToHex(h types.Hash) string

HashToHex convert hash to hex string

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func HexToAddress

func HexToAddress(s string) types.Address

HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.

func HexToHash

func HexToHash(s string) types.Hash

HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.

Types

This section is empty.

Jump to

Keyboard shortcuts

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