util

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

AES CBC PKCS5Padding加/解密

使用 hex.Encode

查看测试文件: aes_cbc_test.go

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 AesDecryptECB added in v0.6.8

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

AES-256-ECB

func AppletDecrypt added in v0.6.8

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

微信小程序/头条小程序

解密小程序敏感信息: 对称解密使用的算法为 AES-128-CBC,数据采用PKCS#7填充。 对称解密的目标密文为 Base64_Decode(encryptedData)。 对称解密秘钥 aeskey = Base64_Decode(session_key), aeskey 是16字节。 对称解密算法初始向量 为Base64_Decode(iv),其中iv由数据接口返回。

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)

IntDateTimeFormat 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 PKCS7UnPadding added in v0.6.8

func PKCS7UnPadding(plantText []byte) []byte

PKCS7UnPadding return unpadding []Byte plantText

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