utils

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SSPrefix        = []byte{0x53, 0x53, 0x35, 0x38, 0x50, 0x52, 0x45}
	SubstratePrefix = []byte{0x2a}
	CessPrefix      = []byte{0x50, 0xac}
)

Functions

func CalcFileSHA256

func CalcFileSHA256(f *os.File) (string, error)

CalcFileSHA256 is used to calculate the sha256 value of the file type.

func CalcPathSHA256

func CalcPathSHA256(fpath string) (string, error)

CalcPathSHA256 is used to calculate the sha256 value of a file with a given path.

func CalcSHA256

func CalcSHA256(data []byte) (string, error)

CalcSHA256 is used to calculate the sha256 value of the data.

func DecodePublicKeyOfCessAccount

func DecodePublicKeyOfCessAccount(address string) ([]byte, error)

func DecodePublicKeyOfSubstrateAccount

func DecodePublicKeyOfSubstrateAccount(address string) ([]byte, error)

func EncodePublicKeyAsCessAccount

func EncodePublicKeyAsCessAccount(publicKey []byte) (string, error)

func EncodePublicKeyAsSubstrateAccount

func EncodePublicKeyAsSubstrateAccount(publicKey []byte) (string, error)

func GetGuid

func GetGuid() (string, error)

Get a unique snowflake ID

func GetRandomcode

func GetRandomcode(length uint8) string

Generate random password

func InterfaceIsNIL

func InterfaceIsNIL(i interface{}) bool

InterfaceIsNIL returns the comparison between i and nil

func IsIPv4

func IsIPv4(ipAddr string) bool

IsIPv4 is used to determine whether ipAddr is an ipv4 address

func IsIPv6

func IsIPv6(ipAddr string) bool

IsIPv6 is used to determine whether ipAddr is an ipv6 address

func PubBytesToString

func PubBytesToString(b []byte) string

func RandSlice

func RandSlice(slice interface{})

RandSlice is used to disrupt the order of elements in the slice

func RandStr

func RandStr(n int) string

func RandomInRange

func RandomInRange(min, max int) int

Get a random integer in a specified range

func RecoverError

func RecoverError(err interface{}) error

RecoverError is used to record the stack information of panic

func VerityAddress

func VerityAddress(address string, prefix []byte) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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