utils

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

*

@author: taco
@Date: 2023/9/1
@Time: 9:30

*

*

@author: taco
@Date: 2023/7/26
@Time: 17:47

*

*

@author: taco
@Date: 2023/7/21
@Time: 13:44

*

*

@author: taco
@Date: 2023/7/21
@Time: 15:40

*

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(data []byte, key []byte) ([]byte, error)

AesDecrypt 解密

func AesDecryptByCTR

func AesDecryptByCTR(dataBase64, key string) string

解密

func AesEncrypt

func AesEncrypt(data []byte, key []byte) ([]byte, error)

AesEncrypt 加密

func AesEncryptByCTR

func AesEncryptByCTR(data, key string) (string, string)

func CheckPassword

func CheckPassword(password string) bool

func CheckPasswordAes

func CheckPasswordAes(password, salt, key, baseCode string) bool

func CreateToken

func CreateToken(exp int, UserId, TenantID uint, privateKey string, loginTime time.Time) (string, int64, error)

func DecryptByAes

func DecryptByAes(data string, key []byte) ([]byte, error)

DecryptByAes Aes 解密

func EnHex

func EnHex(text string) string

func EncryptByAes

func EncryptByAes(data []byte, key []byte) (string, error)

EncryptByAes Aes加密 后 base64 再加

func GenRsaKey

func GenRsaKey() (prvkey, pubkey []byte, err error)

RSA公钥私钥产生

func GenerateTicket

func GenerateTicket(pfx string, l int) string

func IsNumber

func IsNumber(str string) bool

func Md5SumWithString

func Md5SumWithString(hash string, salt string) string

func PKCS5Padding

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

PKCS5填充方式

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

PKCS5 反填充

func Password

func Password(password string, salt string) string

func RandSalt

func RandSalt(n int) string

func Random

func Random() (string, error)

func RsaDecrypt

func RsaDecrypt(ciphertext, keyBytes []byte) ([]byte, error)

私钥解密

func RsaEncrypt

func RsaEncrypt(data, keyBytes []byte) ([]byte, error)

公钥加密

func RsaSignWithSha256

func RsaSignWithSha256(data []byte, keyBytes []byte) ([]byte, error)

签名

func RsaVerySignWithSha256

func RsaVerySignWithSha256(data, signData, keyBytes []byte) (bool, error)

验证

func ToUp

func ToUp(sign string) string

func ZeroPadding

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

Zero填充方式

func ZeroUnPadding

func ZeroUnPadding(origData []byte) []byte

Zero反填充

Types

type CustomClaims

type CustomClaims struct {
	UserId    uint
	TenantID  uint
	LoginTime time.Time
	jwt.StandardClaims
}

func ParseToken

func ParseToken(tokenString, pubKey string) (*CustomClaims, error)

解析 token

Jump to

Keyboard shortcuts

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