utils

package
v0.0.0-...-8e1329c Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GitBranch = "not set"
	GitCommit = "not set"
	BuildTime = C.GoString(C.goBaselibBuildTime())
)
View Source
var ErrDataInvalid error

Functions

func CurrentDate

func CurrentDate() (date string)

CurrentDate 当前日期

func Datetime

func Datetime() (datetime string)

Datetime 当前时间

func Elapsed

func Elapsed(what string) func()

Elapsed 计算函数执行时间.

func IsInteger

func IsInteger(str string) (ok bool)

IsInteger 是否是integer数据

func MMHash

func MMHash(buf []byte) uint64

func Md5File

func Md5File(path string) (string, int64, error)

func Md5Reader

func Md5Reader(reader io.Reader) (string, int64, error)

func Md5hex

func Md5hex(data []byte) string

func MustPwdEncode

func MustPwdEncode(rawPassword string) (encodePassword string)

MustPwdEncode 使用bcrypt算法加密密码, 出错会抛出ERR_SERVER_ERROR异常.

func Now

func Now() (now int64)

Now 当前时间,unix时间戳

func PwdCompare

func PwdCompare(hashedPassword, rawPassword string) error

PwdCompare 比较密码.

func PwdEncode

func PwdEncode(rawPassword string) (string, error)

PwdEncode 使用bcrypt算法加密密码.

func RandomCode

func RandomCode(length int) string

RandomCode 随机指定长度的数字字符串

func RandomInviteCode

func RandomInviteCode(length int) string

RandomInviteCode 生成邀请码.

func RandomString

func RandomString(n int) string

RandomString 随机指定长度的字符串

func Sha1File

func Sha1File(path string) (string, int64, error)

func Sha1Reader

func Sha1Reader(reader io.Reader) (string, int64, error)

func Sha1hex

func Sha1hex(data []byte) string

func Uint32ToBase64

func Uint32ToBase64(value uint32) (base64val string)

Uint32ToBase64 uint32转成base64格式.

func Uint64ToStrID

func Uint64ToStrID(id int64, m1, m2, m3 string) string

func Uint64ToUID

func Uint64ToUID(id int64) (uid string)

func UnixTimestamp

func UnixTimestamp(datetime string) (unixtime int64)

UnixTimestamp 时间转时间戳.

Types

type CheckSum

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

func NewCheckSum

func NewCheckSum(magic string, length int, digest string) (checkSum *CheckSum)

func (*CheckSum) Add

func (c *CheckSum) Add(data string) (newData string)

func (*CheckSum) Check

func (c *CheckSum) Check(data string) (rawData string, err error)

Jump to

Keyboard shortcuts

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