util

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(decodeStr string, key string) (string, error)

AESDecrypt AES CBC decrypt

func AESEncrypt

func AESEncrypt(plainText string, key string) string

AESEncrypt AES CBC encrypt

func AesDecryptECB added in v1.0.8

func AesDecryptECB(encrypted []byte, key []byte) (decrypted []byte)

AesDecryptECB AES-256-ECB decrypt

func AppletDecrypt added in v1.0.8

func AppletDecrypt(sessionKey, encryptedData string, iv string) ([]byte, error)

AppletDecrypt 解密小程序敏感信息

func Decrypt

func Decrypt(data []byte, key []byte) []byte

Decrypt the data with key. data is the bytes to be decrypted. key is the decrypted key. It is the same as the encrypt key.

func Encrypt

func Encrypt(data []byte, key []byte) []byte

Encrypt the data with key. data is the bytes to be encrypted. key is the encrypt key. It is the same as the decrypt key.

func GetUUID

func GetUUID() (string, error)

GetUUID UUID MD5

use:github.com/satori/go.uuid

func GobDecode

func GobDecode(data []byte, to interface{}) error

GobDecode GobDecode

func GobEncode

func GobEncode(data interface{}) ([]byte, error)

GobEncode gob encode

func IntDateTime

func IntDateTime(val int64) (ret string)

IntDateTime returns int64 time to format

func IntDateTimeFormat

func IntDateTimeFormat(val int64, format string) (ret string)

IntDateTimeFormat DateTimeFormat

func MD5

func MD5(str string) string

MD5 编码

32位长度的md5输出,不区分大小与
s:=MD5("123456)

func PKCS5Padding

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

PKCS5Padding PKCS5Padding

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

PKCS5UnPadding PKCS5UnPadding

func PKCS7UnPadding added in v1.0.8

func PKCS7UnPadding(plantText []byte) []byte

PKCS7UnPadding return unpadding []Byte plantText

func TimeFormat

func TimeFormat(t time.Time, format string) string

TimeFormat time.Time format

Types

type MemoryCache

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

MemoryCache memory cache struct

func NewMemoryCache

func NewMemoryCache(defaultHour, cleanupInterval int) *MemoryCache

NewMemoryCache return a new memory cache

func (*MemoryCache) GetCache

func (m *MemoryCache) GetCache(key string, to interface{}) (ok bool, err error)

GetCache return cache data

func (*MemoryCache) RemoveCache

func (m *MemoryCache) RemoveCache(key string) error

RemoveCache delete cache

func (*MemoryCache) SetCache

func (m *MemoryCache) SetCache(key string, value interface{}) error

SetCache set cache to key and return error

type XXTea

type XXTea struct {
	Key string
}

func NewXXTea

func NewXXTea(key string) *XXTea

NewXXTea get new xxtea code

func (*XXTea) DecryptString

func (m *XXTea) DecryptString(str string) (string, error)

DecryptString returns decrypt string and error

func (*XXTea) EncryptString

func (m *XXTea) EncryptString(str string) string

EncryptString returns encrypt string

Jump to

Keyboard shortcuts

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