util

package
v0.0.0-...-e20480a Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecryptECB

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

func AesDecrypt

func AesDecrypt(point string, key string) string

func AesEncrypt

func AesEncrypt(data, key string) string

func AesEncryptToBytes

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

func CurrentAbPath

func CurrentAbPath() (dir string)

CurrentAbPath 获取项目根目录

func GetEnOrChLength

func GetEnOrChLength(text string) int

func GetUuid

func GetUuid() string

GetUuid 获取UUID

func ImageToRGBA

func ImageToRGBA(img image.Image) *image.RGBA

ImageToRGBA 图片转rgba

func OpenPngImage

func OpenPngImage(src string) image.Image

OpenPngImage 打开png图片

func PKCS5Padding

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

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

PKCS5UnPadding 删除pks5填充的尾部数据

func RandString

func RandString(codeLen int) string

func RandomInt

func RandomInt(min, max int) int

Types

type CacheUtil

type CacheUtil struct {
	Data                  map[string]string
	DataRWLock            sync.RWMutex
	CaptchaCacheMaxNumber int
}

func NewCacheUtil

func NewCacheUtil(captchaCacheMaxNumber int) *CacheUtil

func (*CacheUtil) Clear

func (l *CacheUtil) Clear()

func (*CacheUtil) Delete

func (l *CacheUtil) Delete(key string)

func (*CacheUtil) Exists

func (l *CacheUtil) Exists(key string) bool

func (*CacheUtil) Get

func (l *CacheUtil) Get(key string) string

func (*CacheUtil) Set

func (l *CacheUtil) Set(key string, val string, expiresInSeconds int)

type FontUtil

type FontUtil struct {
	Src string
}

func NewFontUtil

func NewFontUtil(src string) *FontUtil

NewFontUtil 字体绝对路径

func (*FontUtil) GetFont

func (f *FontUtil) GetFont() *truetype.Font

GetFont 获取一个字体对象

type ImageUtil

type ImageUtil struct {
	Src       string
	SrcImage  image.Image
	RgbaImage *image.RGBA
	FontPath  string
	Width     int
	Height    int
}

func NewImageUtil

func NewImageUtil(src string, fontPath string) *ImageUtil

NewImageUtil src为绝对路径

func (*ImageUtil) Base64

func (i *ImageUtil) Base64() (string, error)

Base64 为像素设置颜色

func (*ImageUtil) DecodeImageToFile

func (i *ImageUtil) DecodeImageToFile()

DecodeImageToFile 将图片转换为新的文件 调试使用

func (*ImageUtil) IsOpacity

func (i *ImageUtil) IsOpacity(x, y int) bool

IsOpacity 该像素是否透明

func (*ImageUtil) SetArtText

func (i *ImageUtil) SetArtText(text string, fontsize int, point vo.PointVO) error

SetArtText 为图片设置文字

func (*ImageUtil) SetPixel

func (i *ImageUtil) SetPixel(rgba color.RGBA, x, y int)

SetPixel 为像素设置颜色

func (*ImageUtil) SetText

func (i *ImageUtil) SetText(text string, fontsize int, color color.RGBA)

SetText 为图片设置文字

func (*ImageUtil) VagueImage

func (i *ImageUtil) VagueImage(x int, y int)

VagueImage 模糊区域

type RedisUtil

type RedisUtil struct {
	Rdb redis.UniversalClient
}

func NewConfigRedisUtil

func NewConfigRedisUtil(rdsAddr []string, dbUserName, dbPassword string, enableCluster bool, db int) *RedisUtil

func (*RedisUtil) Clear

func (l *RedisUtil) Clear()

func (*RedisUtil) Delete

func (l *RedisUtil) Delete(key string)

func (*RedisUtil) Exists

func (l *RedisUtil) Exists(key string) bool

func (*RedisUtil) Get

func (l *RedisUtil) Get(key string) string

func (*RedisUtil) InitConfigRedis

func (l *RedisUtil) InitConfigRedis(rdsAddr []string, dbUserName, dbPassword string, enableCluster bool, db int)

InitConfigRedis 初始化自定义配置redis客户端(可单机, 可集群)

func (*RedisUtil) Set

func (l *RedisUtil) Set(key string, val string, expiresInSeconds int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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