utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CrtFile []byte
View Source
var JsonConfig = jsoniter.Config{
	EscapeHTML:    true,
	CaseSensitive: true,
}.Froze()
View Source
var KeyFile []byte
View Source
var Rand = rand.New(rand.NewSource(time.Now().UnixMilli()))

Rand 随机函数

Functions

func Any2json

func Any2json(data any, path ...string) gjson.Result

Any2json 转成json

func Base64Decode

func Base64Decode(val string) ([]byte, error)

Base64Decode 解密

func Base64Encode

func Base64Encode[T string | []byte](val T) string

Base64Encode 加密

func BytesToString

func BytesToString(b []byte) string

BytesToString 字节串转字符串

func Charset

func Charset(content []byte, contentType string) ([]byte, string, error)

Charset 网页解码,并返回 编码

func CopySlices

func CopySlices[T any](value []T) []T

func CopySlicess

func CopySlicess[T any](value [][]T) [][]T

func CopyWitchContext

func CopyWitchContext(ctx context.Context, writer io.Writer, reader io.Reader) (err error)

func Decode

func Decode[T string | []byte](txt T, code string) T

Decode 转码

func GetCertData

func GetCertData(cert *x509.Certificate) []byte

func GetCertKeyData

func GetCertKeyData(key *ecdsa.PrivateKey) ([]byte, error)

func GetCertWithCN

func GetCertWithCN(rootCert *x509.Certificate, key *ecdsa.PrivateKey, commonName string) (*x509.Certificate, error)

func GetCertWithCert

func GetCertWithCert(rootCert *x509.Certificate, key *ecdsa.PrivateKey, preCert *x509.Certificate) (*x509.Certificate, error)

func GetContentTypeWithBytes

func GetContentTypeWithBytes(content []byte) string

func GetHosts

func GetHosts(addrTypes ...int) []net.IP

func GetProxyCertWithCert

func GetProxyCertWithCert(preCert *x509.Certificate) (tlsCert tls.Certificate, err error)

func GetProxyCertWithName

func GetProxyCertWithName(serverName string) (tlsCert tls.Certificate, err error)

func GetServerName

func GetServerName(addr string) string

func GetTlsCert

func GetTlsCert(cert *x509.Certificate, key *ecdsa.PrivateKey) (tls.Certificate, error)

func Hex

func Hex(val any) string

func LoadCertData

func LoadCertData(data []byte) (*x509.Certificate, error)

func LoadCertKeyData

func LoadCertKeyData(data []byte) (*ecdsa.PrivateKey, error)

func Md5

func Md5[T string | []byte](val T) [16]byte

Md5 加密

func ParseHost

func ParseHost(host string) (net.IP, int)

func ParseIp

func ParseIp(ip net.IP) int

func Sha1

func Sha1[T string | []byte](val T) []byte

Sha1 加密

func SplitHostPort

func SplitHostPort(address string) (string, int, error)

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes 字符串转字节串

func UrlJoin

func UrlJoin(base, href string) (string, error)

UrlJoin 拼接url

func WrapError

func WrapError(err error, val ...any) error

func ZipDecode

func ZipDecode(ctx context.Context, r *bytes.Buffer, encoding string) (*bytes.Buffer, error)

ZipDecode 压缩解码

Types

This section is empty.

Jump to

Keyboard shortcuts

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