util

package
v0.0.0-...-eaa46e8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

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

AesDecrypt 解密 CBC模式 data:加密的数据, key:秘钥,keyLen:加密长度,一般是16,32,48,56,64等

func AesDecryptBase64

func AesDecryptBase64(data string, key []byte, keyLen int) ([]byte, error)

DecryptByAes base64解码后 Aes 解密

func AesDecryptCBC

func AesDecryptCBC(data string, key []byte, kenLen int) (decrypted []byte)

cbc解密

func AesDecryptCFB

func AesDecryptCFB(encrypted []byte, key []byte, kenLen int) (decrypted []byte)

解密数据,CFB模式需要初始化向量iv,长度和秘钥长度一致。

func AesDecryptECB

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

func AesEncrypt

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

AesEncrypt 加密,CBC模式 ,data:加密前的数据, key:秘钥,keyLen:加密长度,一般是16,32,48,56,64等

func AesEncryptBase64

func AesEncryptBase64(data []byte, key []byte, keyLen int) (string, error)

EncryptByAes Aes加密 后 base64

func AesEncryptCBC

func AesEncryptCBC(origData []byte, key []byte, kenLen int) (result string)

=================== CBC ====================== cbc加密,origData:需要加密的字符,key:秘钥

func AesEncryptCFB

func AesEncryptCFB(origData []byte, key []byte, kenLen int) (encrypted []byte)

=================== CFB ====================== 加密数据,CFB模式需要初始化向量iv,长度和秘钥长度一致。

func AesEncryptECB

func AesEncryptECB(origData []byte, key []byte) (encrypted []byte)

=================== ECB ======================

func CheckApkAudit

func CheckApkAudit(inputFile string) (filetype string, err error)

判断文件是否zip

func CheckDirExists

func CheckDirExists(pathDir string) bool

判断是否文件夹

func CheckDocAudit

func CheckDocAudit(inputFile string) (filetype string, err error)

判断是否为文档类型

func CheckExists

func CheckExists(pathDir string) bool

判断文件或者文件夹是否存在

func CheckFileExists

func CheckFileExists(pathDir string) bool

判断文件是否存在

func CheckImageAudit

func CheckImageAudit(inputFile string) (filetype string, rr error)

判断文件是否图片类型

func CheckIp

func CheckIp(ip string) bool

检查是否IP规范

func CheckNumber

func CheckNumber(s string) bool

是否数字

func CheckTsAudit

func CheckTsAudit(inputFile string) (err error)

判断文件是否为ts

func CheckVideoAudit

func CheckVideoAudit(inputFile string) (fileType string, err error)

判断文件是否为视频文件类型

func CheckZipAudit

func CheckZipAudit(inputFile string) (filetype string, err error)

判断文件是否zip类型

func CopyFile

func CopyFile(src, dst string) (n int64, err error)

复制文件,src:源文件路径,dst:目标文件路径 目标文件,如果文件夹不存在,自动创建目录

func Download

func Download(url, filepath string) error

下载文件,大文件

func GenerateSelfSignedCert

func GenerateSelfSignedCert() (certPem []byte, keyPem []byte, err error)

自己生成证书,

func Get

func Get(_url string, _time int) (result []byte, err error)

发送get请求

func GetAnyString

func GetAnyString(value interface{}) string

转换任意类型为字符串

func GetFileMd5

func GetFileMd5(filePath string) string

得到文件的md5值

func GetFileSize

func GetFileSize(filePath string) int64

得到文件大小

func GetFormatBytes

func GetFormatBytes(total uint64) string

把字节转换为字符串 B,Kb,Mb,Gb

func GetLocalIP

func GetLocalIP() (ip string, err error)

得到本机IP,可以过滤其他IP地址,是请求的IP

func GetMd5

func GetMd5(m string) string

得到md5 32位

func GetNow

func GetNow() string

得到当前时间 返回格式2006-01-02 15:04:05

func GetNowDateFormat

func GetNowDateFormat(layout string) string

根据时间格式返回,layout 时间格式,2006-01-02 15:04:05

func GetNowFormatToUnix

func GetNowFormatToUnix(date string) int64

把时间日期转换为时间差(秒) date 2006-01-02 15:04:05

func GetNowTimeFormatUnix

func GetNowTimeFormatUnix(date, layout string) int64

把时间日期转换为时间戳(秒)

func GetNowTimeUnix

func GetNowTimeUnix(unix int64, layout string) string

把时间戳(秒)转换为日期格式 unix 时间戳(秒),layout 时间格式,2006-01-02 15:04:05

func GetPath

func GetPath() string

得到当前执行文件的路径,如果是测试环境,返回"./", 路径后面带/

func GetRandDateUUID

func GetRandDateUUID(lenth int) string

根据时间生成随机字符串,一般是前面时间yyyyMMddHHmmss后面的随机字符串长度为lenth

func GetRandUUID

func GetRandUUID(length int) string

得到随机字符串,默认是20位

func GetTlsConfig

func GetTlsConfig() (tlsConfig *tls.Config, err error)

生成证书的TLS配置

tlsConfig, _ := internal.GetTlsConfig()
	server := &http.Server{
		Addr:      bindAddress,
		Handler:   r,
		TLSConfig: tlsConfig,
	}
	err = server.ListenAndServeTLS("", "")

func GetTlsVersionToString

func GetTlsVersionToString(version uint16) string

检查当前的证书版本号

func Json

func Json(_url string, param interface{}, _times int) (result []byte, err error)

发送json

func Mkdir

func Mkdir(dir string) (e error)

func Post

func Post(_url string, param map[string]interface{}, _times int) (result []byte, err error)

发送post请求,默认5秒,支持https,支持超时时间设置,默认5秒,一般用于表单提交

func RunCommand

func RunCommand(cmd string) (string, error)

自动识别系统

func TrimAllSpace

func TrimAllSpace(str string) string

删除所有的空格字符串,包含空格、制表符、换行等。 strings.TrimSpace(str) 删除左右空格

Types

type ManifestEncoder

type ManifestEncoder struct {
	Name        string
	VersionCode int
	VersionName string
	Package     string
}

得到apk的基本信息

func (*ManifestEncoder) EncodeToken

func (e *ManifestEncoder) EncodeToken(t xml.Token) error

func (*ManifestEncoder) Flush

func (e *ManifestEncoder) Flush() error

func (*ManifestEncoder) OpenApk

func (ths *ManifestEncoder) OpenApk(filePath string) error

Directories

Path Synopsis
Package apkparser parses AndroidManifest.xml and resources.arsc from Android APKs.
Package apkparser parses AndroidManifest.xml and resources.arsc from Android APKs.
flate
Package flate implements the DEFLATE compressed data format, described in RFC 1951.
Package flate implements the DEFLATE compressed data format, described in RFC 1951.

Jump to

Keyboard shortcuts

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