codec

package
v1.2.9-sp2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: AGPL-3.0 Imports: 43 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AESECBEncryptWithPKCS7Padding = AESECBEncrypt
View Source
var AESGCMEncryptWithNonceSize16 = AESGCMEncrypt
View Source
var DoubleDecodeUrl = func(i string) (string, error) {
	raw, err := url.QueryUnescape(i)
	if err != nil {
		return "", err
	}

	return url.QueryUnescape(raw)
}
View Source
var DoubleEncodeUrl = func(i interface{}) string {
	return url.QueryEscape(EncodeUrlCode(i))
}
View Source
var EscapeHtmlString = html.EscapeString
View Source
var PKCS7Padding = sm4.PKCS7Padding
View Source
var PKCS7UnPadding = sm4.PKCS7UnPadding
View Source
var PathEscape = url.PathEscape
View Source
var StrConvQuote = func(s string) string {
	raw := []byte(s)
	var buf bytes.Buffer
	buf.WriteString("\"")
	for _, b := range raw {
		switch true {
		case b >= 'a' && b <= 'z':
			fallthrough
		case b >= 'A' && b <= 'Z':
			fallthrough
		case b >= '0' && b <= '9':
			buf.WriteByte(b)
		default:
			buf.WriteString(fmt.Sprintf(`\x%02x`, b))
		}
	}
	buf.WriteString("\"")
	return buf.String()
}
View Source
var StrConvUnquote = strconv.Unquote
View Source
var UnescapeHtmlString = html.UnescapeString

Functions

func AESCBCDecryptWithPKCS7Padding

func AESCBCDecryptWithPKCS7Padding(key []byte, i interface{}, iv []byte) ([]byte, error)

func AESCBCDecryptWithZeroPadding

func AESCBCDecryptWithZeroPadding(key []byte, i interface{}, iv []byte) ([]byte, error)

func AESCBCEncryptWithPKCS7Padding

func AESCBCEncryptWithPKCS7Padding(key []byte, i interface{}, iv []byte) ([]byte, error)

func AESCBCEncryptWithZeroPadding

func AESCBCEncryptWithZeroPadding(key []byte, i interface{}, iv []byte) ([]byte, error)

func AESECBDecryptWithPKCS7Padding

func AESECBDecryptWithPKCS7Padding(key []byte, i interface{}, iv []byte) ([]byte, error)

func AESECBDecryptWithZeroPadding

func AESECBDecryptWithZeroPadding(key []byte, i interface{}, iv []byte) ([]byte, error)

func AESECBEncrypt

func AESECBEncrypt(key []byte, i interface{}, iv []byte) ([]byte, error)

func AESECBEncryptWithZeroPadding

func AESECBEncryptWithZeroPadding(key []byte, i interface{}, iv []byte) ([]byte, error)

func AESGCMDecrypt

func AESGCMDecrypt(key []byte, data interface{}, nonce []byte) ([]byte, error)

func AESGCMDecryptWithNonceSize

func AESGCMDecryptWithNonceSize(key []byte, data interface{}, nonceRaw []byte, nonceSize int) ([]byte, error)

func AESGCMDecryptWithNonceSize12

func AESGCMDecryptWithNonceSize12(key []byte, data interface{}, nonce []byte) ([]byte, error)

func AESGCMDecryptWithNonceSize16

func AESGCMDecryptWithNonceSize16(key []byte, data interface{}, nonce []byte) ([]byte, error)

func AESGCMEncrypt

func AESGCMEncrypt(key []byte, data interface{}, nonceRaw []byte) ([]byte, error)

//AES GCM 加密后的payload shiro 1.4.2版本更换为了AES-GCM加密方式

func AES_GCM_Encrypt(key []byte, Content []byte) string {
	block, _ := aes.NewCipher(key)
	nonce := make([]byte, 16)
	io.ReadFull(rand.Reader, nonce)
	aesgcm, _ := cipher.NewGCMWithNonceSize(block, 16)
	ciphertext := aesgcm.Seal(nil, nonce, Content, nil)
	return base64.StdEncoding.EncodeToString(append(nonce, ciphertext...))
}

func AESGCMEncryptWithNonceSize

func AESGCMEncryptWithNonceSize(key []byte, data interface{}, nonceRaw []byte, nonceSize int) ([]byte, error)

func AESGCMEncryptWithNonceSize12

func AESGCMEncryptWithNonceSize12(key []byte, data interface{}, nonceRaw []byte) ([]byte, error)

func AnyToBytes added in v1.2.6

func AnyToBytes(i interface{}) (result []byte)

func AnyToString added in v1.2.6

func AnyToString(i interface{}) string

func Atob added in v1.2.6

func Atob(i string) bool

func Atof added in v1.2.6

func Atof(i string) float64

func Atoi added in v1.2.6

func Atoi(i string) int

func CharDetect

func CharDetect(raw interface{}) ([]chardet.Result, error)

func CharDetectBest

func CharDetectBest(raw interface{}) (*chardet.Result, error)

func DESCBCDec

func DESCBCDec(key []byte, data []byte, iv []byte) ([]byte, error)

func DESCBCDecEx added in v1.2.4

func DESCBCDecEx(key, data, iv []byte, isTripleDES bool) ([]byte, error)

func DESCBCEnc

func DESCBCEnc(key []byte, data []byte, iv []byte) ([]byte, error)

func DESCBCEncEx added in v1.2.4

func DESCBCEncEx(key []byte, data []byte, iv []byte, isTripleDES bool) ([]byte, error)

func DESECBDec

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

func DESECBDecEx added in v1.2.4

func DESECBDecEx(key []byte, data []byte, isTripleDES bool) ([]byte, error)

func DESECBEnc

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

func DESECBEncEx added in v1.2.4

func DESECBEncEx(key []byte, data []byte, isTripleDES bool) ([]byte, error)

func DecodeBase32 added in v1.2.4

func DecodeBase32(i string) ([]byte, error)

func DecodeBase64

func DecodeBase64(i string) ([]byte, error)

func DecodeBase64Url

func DecodeBase64Url(i interface{}) ([]byte, error)

func DecodeHex

func DecodeHex(i string) ([]byte, error)

func Decodebig5

func Decodebig5(s []byte) ([]byte, error)

Decodebig5 converts BIG5 to UTF-8

func Decodegbk

func Decodegbk(s []byte) ([]byte, error)

Decodegbk converts GBK to UTF-8

func EncodeBase32 added in v1.2.4

func EncodeBase32(i interface{}) string

func EncodeBase64

func EncodeBase64(i interface{}) string

func EncodeBase64Url

func EncodeBase64Url(i interface{}) string

func EncodeByType added in v1.2.8

func EncodeByType(t string, i interface{}) string

func EncodeHtmlEntity

func EncodeHtmlEntity(i interface{}) string

func EncodeHtmlEntityHex

func EncodeHtmlEntityHex(i interface{}) string

func EncodeToHex

func EncodeToHex(i interface{}) string

func EncodeUrlCode

func EncodeUrlCode(i interface{}) string

func Encodebig5

func Encodebig5(s []byte) ([]byte, error)

Encodebig5 converts UTF-8 to BIG5

func EscapeInvalidUTF8Byte

func EscapeInvalidUTF8Byte(s []byte) string

func ForceQueryUnescape added in v1.2.8

func ForceQueryUnescape(s string) string

func GB18030ToUtf8

func GB18030ToUtf8(s []byte) ([]byte, error)

func GBKSafeString

func GBKSafeString(s []byte) (string, error)

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

func GenerateSM2PrivateKeyHEX

func GenerateSM2PrivateKeyHEX() ([]byte, []byte, error)

func GenerateSM2PrivateKeyPEM

func GenerateSM2PrivateKeyPEM() ([]byte, []byte, error)

func HTTPChunkedDecode

func HTTPChunkedDecode(raw []byte) ([]byte, error)

func HTTPChunkedDecodeWithRestBytes added in v1.2.6

func HTTPChunkedDecodeWithRestBytes(raw []byte) ([]byte, []byte)

func HTTPChunkedDecoderWithRestBytes added in v1.2.6

func HTTPChunkedDecoderWithRestBytes(raw io.Reader) ([]byte, []byte, io.Reader, error)

func HTTPChunkedEncode

func HTTPChunkedEncode(raw []byte) []byte

func HZGB2312ToUtf8

func HZGB2312ToUtf8(s []byte) ([]byte, error)

func HmacMD5

func HmacMD5(key, data interface{}) []byte

func HmacSM3

func HmacSM3(key, data interface{}) []byte

func HmacSha1

func HmacSha1(key, data interface{}) []byte

func HmacSha256

func HmacSha256(key, data interface{}) []byte

func HmacSha512

func HmacSha512(key, data interface{}) []byte

func IsGBK

func IsGBK(data []byte) bool

func IsUtf8

func IsUtf8(data []byte) bool

func Itoa added in v1.2.8

func Itoa(i int) string

func JsonUnicodeDecode

func JsonUnicodeDecode(i string) string

func JsonUnicodeEncode

func JsonUnicodeEncode(i string) string

func MMH3Hash128

func MMH3Hash128(i interface{}) string

func MMH3Hash128x64

func MMH3Hash128x64(i interface{}) string

func MMH3Hash32

func MMH3Hash32(i interface{}) int64

func Md5

func Md5(i interface{}) string

func MustPKCS5UnPadding added in v1.2.2

func MustPKCS5UnPadding(origData []byte) ([]byte, error)

func PKCS5Padding

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

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func PathUnescape

func PathUnescape(s string) (string, error)

func QueryEscape

func QueryEscape(s string) string

func QueryUnescape

func QueryUnescape(s string) (string, error)

func RC4Decrypt

func RC4Decrypt(cipherKey []byte, cipherText []byte) ([]byte, error)

func RC4Encrypt

func RC4Encrypt(cipherKey []byte, plainText []byte) ([]byte, error)

func RandomUpperAndLower

func RandomUpperAndLower(s string) string

func ReadHTTPChunkedDataWithFixed added in v1.2.6

func ReadHTTPChunkedDataWithFixed(ret []byte) (data []byte, fixedChunked []byte, rest []byte)

func SM2DecryptASN1

func SM2DecryptASN1(priKey []byte, data []byte) ([]byte, error)

func SM2DecryptASN1WithPassword

func SM2DecryptASN1WithPassword(priKey []byte, data []byte, password []byte) ([]byte, error)

func SM2DecryptC1C2C3

func SM2DecryptC1C2C3(priKey []byte, data []byte) ([]byte, error)

func SM2DecryptC1C2C3WithPassword

func SM2DecryptC1C2C3WithPassword(priKey []byte, data []byte, password []byte) ([]byte, error)

func SM2DecryptC1C3C2

func SM2DecryptC1C3C2(priKey []byte, data []byte) ([]byte, error)

func SM2DecryptC1C3C2WithPassword

func SM2DecryptC1C3C2WithPassword(priKey []byte, data []byte, password []byte) ([]byte, error)

func SM2EncryptASN1

func SM2EncryptASN1(pubKey []byte, data []byte) ([]byte, error)

func SM2EncryptC1C2C3

func SM2EncryptC1C2C3(pubKey []byte, data []byte) ([]byte, error)

func SM2EncryptC1C3C2

func SM2EncryptC1C3C2(pubKey []byte, data []byte) ([]byte, error)

func SM3

func SM3(raw interface{}) []byte

func SM4CBCDec

func SM4CBCDec(key []byte, data interface{}, iv []byte) ([]byte, error)

func SM4CBCEnc

func SM4CBCEnc(key []byte, data interface{}, iv []byte) ([]byte, error)

func SM4CFBDec

func SM4CFBDec(key []byte, data interface{}, iv []byte) ([]byte, error)

func SM4CFBEnc

func SM4CFBEnc(key []byte, data interface{}, iv []byte) ([]byte, error)

func SM4ECBDec

func SM4ECBDec(key []byte, data interface{}, iv []byte) ([]byte, error)

func SM4ECBEnc

func SM4ECBEnc(key []byte, data interface{}, iv []byte) ([]byte, error)

func SM4GCMDec

func SM4GCMDec(key []byte, data interface{}, iv []byte) ([]byte, error)

func SM4GCMEnc

func SM4GCMEnc(key []byte, data interface{}, iv []byte) ([]byte, error)

func SM4OFBDec

func SM4OFBDec(key []byte, data interface{}, iv []byte) ([]byte, error)

func SM4OFBEnc

func SM4OFBEnc(key []byte, data interface{}, iv []byte) ([]byte, error)

func Sha1

func Sha1(i interface{}) string

func Sha224

func Sha224(i interface{}) string

func Sha256

func Sha256(i interface{}) string

func Sha384

func Sha384(i interface{}) string

func Sha512

func Sha512(i interface{}) string

func StrConvUnquoteForce added in v1.2.8

func StrConvUnquoteForce(s string) []byte

func TripleDES_CBCDec added in v1.2.4

func TripleDES_CBCDec(key []byte, data []byte, iv []byte) ([]byte, error)

func TripleDES_CBCEnc added in v1.2.4

func TripleDES_CBCEnc(key []byte, data []byte, iv []byte) ([]byte, error)

func TripleDES_ECBDec added in v1.2.4

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

func TripleDES_ECBEnc added in v1.2.4

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

func UrlUnicodeDecode added in v1.2.9

func UrlUnicodeDecode(s string) string

func Utf8ToGB18030

func Utf8ToGB18030(s []byte) ([]byte, error)

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

func Utf8ToHZGB2312

func Utf8ToHZGB2312(s []byte) ([]byte, error)

func ZeroPadding

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

func ZeroUnPadding

func ZeroUnPadding(originData []byte) []byte

Types

type AutoDecodeResult

type AutoDecodeResult struct {
	Type        string
	TypeVerbose string
	Origin      string
	Result      string
}

func AutoDecode

func AutoDecode(i interface{}) []*AutoDecodeResult

Jump to

Keyboard shortcuts

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