common

package
v0.0.0-...-59da782 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: GPL-3.0 Imports: 22 Imported by: 0

README

some useful & common utils

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSign = errors.New("ErrSign")
)

Functions

func AesCBCDecrypt

func AesCBCDecrypt(encryptData, key, iv []byte) ([]byte, error)

func AesCBCEncrypt

func AesCBCEncrypt(origData, key, iv []byte) ([]byte, error)

func BoolToString

func BoolToString(b bool) string

func CheckPub

func CheckPub(bytes []byte, crptoType string) error

func CheckSign

func CheckSign(data []byte, uid []byte, sign []byte) error

func CopyFile

func CopyFile(dstName, srcName string) (written int64, err error)

func CstTime

func CstTime(timeStr string) time.Time

func FileNameNoExt

func FileNameNoExt(fpath string) string

func Float64ToString

func Float64ToString(data float64, num int) string

func GenKey

func GenKey() (priv *[64]byte, err error)

func GenKeyWithPassword

func GenKeyWithPassword(password string) (*[64]byte, error)

func GetPub

func GetPub(key *[64]byte) string

func HexToPrivkey

func HexToPrivkey(priv string) *[64]byte

func HttpGet

func HttpGet(url string) ([]byte, error)

func IntToString

func IntToString(data interface{}) string

func JSONRPCPost

func JSONRPCPost(url string, payload []byte) ([]byte, error)

func Max

func Max(first int64, args ...int64) int64

func Min

func Min(first int64, args ...int64) int64

func PKCS5Padding

func PKCS5Padding(cipherText []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(encrypt []byte) []byte

func RandBytes

func RandBytes(n int) []byte

func RandFloat32

func RandFloat32() float32

func RandInstructionId

func RandInstructionId() int64

func RandInt

func RandInt() int

func RandInt16

func RandInt16() int16

func RandInt32

func RandInt32() int32

func RandInt64

func RandInt64() int64

func RandStr

func RandStr(length int) string

Constructs an alphanumeric string of given length.

func RandTime

func RandTime() time.Time

func RandUint

func RandUint() uint

func RandUint16

func RandUint16() uint16

func RandUint16Exp

func RandUint16Exp() uint16

Distributed pseudo-exponentially to test for various cases

func RandUint32

func RandUint32() uint32

func RandUint32Exp

func RandUint32Exp() uint32

Distributed pseudo-exponentially to test for various cases

func RandUint64

func RandUint64() uint64

func RandUint64Exp

func RandUint64Exp() uint64

Distributed pseudo-exponentially to test for various cases

func Round

func Round(f float64, n int) float64

func RoundMin

func RoundMin(f float64, n int) float64

func Sec2YYMMDDhhmmss

func Sec2YYMMDDhhmmss(sec int64) string

func Signdata

func Signdata(priv *[64]byte, data []byte) []byte

func String2BaseInt64

func String2BaseInt64(num string) int64

9782.13 --> 978213000000 cause 9782.13*1e8 --> 978212999999

func StringConnect

func StringConnect(data []string) string

func StringToBool

func StringToBool(str string) bool

func StringToFloat64

func StringToFloat64(str string) float64

func StringToInt32

func StringToInt32(str string) int32

func StringToInt64

func StringToInt64(str string) int64

func Time2YYMMDDhhmmss

func Time2YYMMDDhhmmss(t time.Time) string

func TimeNowUnix

func TimeNowUnix() int64

TimeNowYYMMDDhhmmss kk

func TimeNowUnixNano

func TimeNowUnixNano() int64

ns

func TimeNowYYMMDD

func TimeNowYYMMDD() string

func TimeNowYYMMDDhhmmss

func TimeNowYYMMDDhhmmss() string

TimeNowYYMMDDhhmmss kk

func ToCstTime

func ToCstTime(layout string, timeStr string) time.Time

func ToInt64

func ToInt64(o interface{}) int64

func ToString

func ToString(v interface{}) string

func UnixNow

func UnixNow() int64

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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