utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG bool

DEBUG 是否开启打印调试信息

Functions

func ApiRequest

func ApiRequest(eapiOption EapiOption, options RequestData) (result string, header http.Header, err error)

ApiRequest 返回内容未加密的 API 请求

func CacheKeyEncrypt

func CacheKeyEncrypt(data string) (encrypted []byte)

CacheKeyEncrypt cache_key 加密

func ChooseUserAgent

func ChooseUserAgent() string

ChooseUserAgent 随机 UserAgent

func CreateNewRequest

func CreateNewRequest(data string, url string, options RequestData) (answer string, resHeader http.Header, err error)

CreateNewRequest 创建 eapi 请求

func DetectFileType

func DetectFileType(file []byte) (fileType, fileSubtype string)

DetectFileType 检测文件类型

func EapiDecrypt

func EapiDecrypt(encrypted []byte) (decrypted []byte)

EapiDecrypt eapi 解密

func EapiEncrypt

func EapiEncrypt(data string) (encrypted []byte)

EapiEncrypt eapi 加密

func EapiRequest

func EapiRequest(eapiOption EapiOption, options RequestData) (result string, header http.Header, err error)

EapiRequest 返回内容加密的 API 请求

func Format2Params

func Format2Params(str string) (data string)

Format2Params 拼接字符串

func ImageSize

func ImageSize(file []byte) (width, height int, err error)

ImageSize 获取图片尺寸

func MarkerDecrypt

func MarkerDecrypt(encrypted []byte) (decrypted []byte)

MarkerDecrypt 163 key 解密

func MarkerEncrypt

func MarkerEncrypt(data string) (encrypted []byte)

MarkerEncrypt 163 key 加密

func RandHex

func RandHex(n int) []byte

RandHex 生成随机十六进制字符串

func RawRequest

func RawRequest(url string, options RequestData) (result string, err error)

RawRequest 用于上传文件

func ReadFile

func ReadFile(filePath string) (b []byte, err error)

ReadFile 读取文件

func SetLogger

func SetLogger(logger Logger)

SetLogger 设置日志记录器

func SpliceStr

func SpliceStr(path string, data string) (result string)

SpliceStr 拼接字符串

Types

type EapiOption

type EapiOption struct {
	Json string
	Path string
	Url  string
}

EapiOption eapi 请求所需要的参数

type Headers

type Headers []struct {
	Name  string
	Value string
}

Headers 自定义 Headers 数据类型 (仅对于非 eapi 有效)

type Logger

type Logger interface {
	Println(v ...interface{})
	Printf(format string, v ...interface{})
}

Logger 日志接口

type RequestData

type RequestData struct {
	Cookies []*http.Cookie
	Headers Headers
	Body    string
}

RequestData 传入请求数据类型

Jump to

Keyboard shortcuts

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