util

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

AES CBC PKCS5Padding加/解密

使用 hex.Encode

查看测试文件: aes_cbc_test.go

memory cache util

http client 使用github.com/imroc/req库 返回string,如果需要到struct,需要自己反序列化

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecrypt

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

AESDecrypt 解码

func AESEncrypt

func AESEncrypt(plainText string, key string) string

AESEncrypt AES CBC encrypt

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 FileExist

func FileExist(file string) error

FileExist return an error when a file does not exist

func GetUUID

func GetUUID() (string, error)

GetUUID UUID MD5

use:github.com/satori/go.uuid

func GobDecode added in v0.2.2

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

GobDecode GobDecode

func GobEncode added in v0.2.2

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

GobEncode gob encode

func HttpGet

func HttpGet(url string) (ret string, err error)

HttpGet http get

func HttpPost

func HttpPost(url string, param req.Param) (ret string, err error)

HttpPost http post

func IntDateTime

func IntDateTime(val int64) (ret string)

IntDateTime IntDateTime

func IntDateTimeFormat

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

DateTimeFormat DateTimeFormat

func MD5

func MD5(str string) string

MD5 编码

32位长度的md5输出,不区分大小与
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 TimeFormat

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

TimeFormat 格式化时间显示

Types

type MemoryCache added in v0.2.2

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

MemoryCache memory cache struct

func NewMemoryCache added in v0.2.2

func NewMemoryCache(defaultHour, cleanupInterval int) *MemoryCache

NewMemoryCache return a new memory cache

func (*MemoryCache) GetCache added in v0.2.2

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

GetCache return cache data

func (*MemoryCache) RemoveCache added in v0.2.2

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

RemoveCache delete cache

func (*MemoryCache) SetCache added in v0.2.2

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

func (*XXTea) DecryptString

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

DecryptString DecryptString

func (*XXTea) EncryptString

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

EncryptString EncryptString

Jump to

Keyboard shortcuts

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