codec

package
v1.2.0-sp8 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: AGPL-3.0 Imports: 40 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 PathUnescape = url.PathUnescape
View Source
var QueryEscape = url.QueryEscape
View Source
var QueryUnescape = url.QueryUnescape
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 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 CharDetect

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

func CharDetectBest

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

func DESCBCDec

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

func DESCBCEnc

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

func DESECBDec

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

func DESECBEnc

func DESECBEnc(key []byte, data []byte) ([]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 EncodeBase64

func EncodeBase64(i interface{}) string

func EncodeBase64Url

func EncodeBase64Url(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 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 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 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 PKCS5Padding

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

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

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 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 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