util

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UTF8    = Charset("UTF-8")
	GB18030 = Charset("GB18030")
	GBK     = Charset("GBK")
)

Variables

This section is empty.

Functions

func AssertMarshal

func AssertMarshal(v interface{}) string

func Base64Decode

func Base64Decode(str string) (string, error)

base64 decode

func Base64Encode

func Base64Encode(str string) string

base64 encode

func ConvertByte2String

func ConvertByte2String(byte []byte, charset Charset) string

func Des3Decrypt

func Des3Decrypt(key3Des []byte, sec string) (string, error)

3des解密

func Des3Encrypt

func Des3Encrypt(key3Des []byte, source string) (string, error)

3des加密

func DesDecrypt

func DesDecrypt(crypted, key []byte) ([]byte, error)

func DesEncrypt

func DesEncrypt(origData, key []byte) ([]byte, error)

func ExecCmd

func ExecCmd(dir string, str string) (string, error)

执行命令

func ExecCmd2

func ExecCmd2(ctx context.Context, cmd string) (string, error)

func FunFuncName

func FunFuncName() string

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

func GetDateByN

func GetDateByN(n int) int64

获取当前日期前后n天对应的日期证书,0代表获取当前日期整数

func GetFieldName

func GetFieldName(t reflect.Type) (map[string]string, error)

func GetHmac

func GetHmac(key string, data string) string

加密哈希

func GetHmacSha256

func GetHmacSha256(key string, data string) string

func GetIndexByWeigth

func GetIndexByWeigth(data []int) int

func GetMd5

func GetMd5(data string) string

func GetMysqlParam

func GetMysqlParam(n int) string

func GetPosInfo

func GetPosInfo() (string, int)

func GetPosInfoStr

func GetPosInfoStr() string

func GetSecondByDay00

func GetSecondByDay00() int64

获取当前日期(20170802)零点对应的Unix时间戳

func GetSecondFromDay

func GetSecondFromDay() int64

获取整天以来的秒数

func GetSecondFromHour

func GetSecondFromHour() int64

获取整点以来的秒数

func GetSecondFromMonth

func GetSecondFromMonth() int64

获取整月以来的秒数

func GetSecondFromWeek

func GetSecondFromWeek() int64

获取整周以来的秒数

func GetSha1

func GetSha1(data string) string

func GetSignal

func GetSignal() int

func GetTDayByUnixTime

func GetTDayByUnixTime(nowUnix int64) int64

根据时间戳获取对应日期整数

func IsGBK

func IsGBK(data []byte) bool

func IsUtf8

func IsUtf8(data []byte) bool

func PKCS5Padding

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

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func PathExists

func PathExists(path string) bool

判断文件夹是否存在

func Profiling

func Profiling(msg string) func()

统计某函数执行时间 使用方式 defer utils.Profiling("test")()

func RandMN

func RandMN(min int, max int) int

func RsaDecrypt

func RsaDecrypt(privateKey []byte, origData string) ([]byte, error)

rsa解密

func RsaEncrypt

func RsaEncrypt(publicKey []byte, data []byte) (string, error)

rsa加密

func RunFuncName

func RunFuncName() string

func TripleDesDecrypt

func TripleDesDecrypt(crypted, key []byte) ([]byte, error)

3DES解密

func TripleDesEncrypt

func TripleDesEncrypt(origData, key []byte) ([]byte, error)

3DES加密

func UrlDecode

func UrlDecode(str string) (string, error)

url decode string

func UrlEncode

func UrlEncode(str string) string

url encode string, is + not %20

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

func ZeroPadding

func ZeroPadding(ciphertext []byte, blockSize int) []byte

func ZeroUnPadding

func ZeroUnPadding(origData []byte) []byte

Types

type Charset

type Charset string

type TplJson

type TplJson struct {
	Length int                      `json:"length"`
	Data   []map[string]interface{} `json:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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