encry

package
v0.2.38 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AES128CBCDecrypt

func AES128CBCDecrypt(src string, sKey string, ivParameter string) string

解密 参数src:加密结果base64的 参数sKey:加密密钥,非base64的 参数ivParameter:加密向量,非base64的 返回值:原始文本内容

func AES128CBCEncrypt

func AES128CBCEncrypt(src string, sKey string, ivParameter string) string

加密 参数src:原始文本 参数sKey:加密密钥,非base64的 参数ivParameter:加密向量,非base64的 返回值:base64的加密结果

func Aes128Decrypt

func Aes128Decrypt(crypted, key []byte, IV []byte) ([]byte, error)

AES-128解密

func Aes128Encrypt

func Aes128Encrypt(origData, key []byte, IV []byte) ([]byte, error)

AES-128加密

func Base64Decode

func Base64Decode(str string) string

base64解码

func Base64Encode

func Base64Encode(str string) string

base64编码

func Base64RawDecode

func Base64RawDecode(str string) string

base64STD解码

func Base64RawEncode

func Base64RawEncode(str string) string

base64Raw编码

func Base64StdDecode

func Base64StdDecode(str string) string

base64STD解码

func Base64StdEncode

func Base64StdEncode(str string) string

base64STD编码

func CalToken

func CalToken(redirectURL, partnerKey string) (result string)

计算token 虾皮api需要用到

func DesDecryptCBC

func DesDecryptCBC(src, key string) string

CBC解密 参数src:要解密的数据 参数key:密钥,长度必须是8位数不能超过 返回值:解密后的数据

func DesDecryptECB

func DesDecryptECB(src, key string) string

ECB解密 参数src:要解密的数据 参数key:密钥,长度必须是8位数不能超过 返回值:解密后的数据

func DesEncryptCBC

func DesEncryptCBC(src, key string) string

CBC加密 参数src:要加密的数据 参数key:密钥,长度必须是8位数不能超过 返回值:加密后的数据

func DesEncryptECB

func DesEncryptECB(src, key string) string

ECB加密 参数src:要加密的数据 参数key:密钥,长度必须是8位数不能超过 返回值:加密后的数据

func HMACSHA256 added in v0.0.33

func HMACSHA256(data []byte, key []byte) []byte

HMACSHA256

func Hmac

func Hmac(str string, key string) string

hmac加密

func HmacHex

func HmacHex(str string, key string) string

hmac+hex加密

func HmacSHA1 added in v0.0.13

func HmacSHA1(str string, key string) string

HmacSHA1 签名采用HmacSHA1算法 + Base64,编码采用UTF-8

func Md5

func Md5(str string) string

md5加密

func PKCS5Padding

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

明文补码算法

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

明文减码算法

func Rsa2

func Rsa2(origData string, block []byte) (sign string)

Rsa2 加密

func RsaDecrypt

func RsaDecrypt(data string, privateKey string) string

Rsa解密 参数data:要解密的数据 privateKey:私钥 返回值:解密后数据

func RsaDecryptByte

func RsaDecryptByte(ciphertext []byte, privateKey string) ([]byte, error)

Rsa解密

func RsaEncrypt

func RsaEncrypt(data string, publicKey string) string

Rsa加密 参数data:要加密的数据 参数publicKey:公钥 返回值:加密后数据

func RsaEncryptByte

func RsaEncryptByte(data []byte, publicKey string) ([]byte, error)

* RSA加密解密实例: m := security.RsaEncrypt("xfdsfsd", ` -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDZsfv1qscqYdy4vY+P4e3cAtmv ppXQcRvrF1cB4drkv0haU24Y7m5qYtT52Kr539RdbKKdLAM6s20lWy7+5C0Dgacd wYWd/7PeCELyEipZJL07Vro7Ate8Bfjya+wltGK9+XNUIHiumUKULW4KDx21+1NL AUeJ6PeW+DAkmJWF6QIDAQAB -----END PUBLIC KEY----- `)

fmt.Println(security.RsaDecrypt(m, `

-----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQDZsfv1qscqYdy4vY+P4e3cAtmvppXQcRvrF1cB4drkv0haU24Y 7m5qYtT52Kr539RdbKKdLAM6s20lWy7+5C0DgacdwYWd/7PeCELyEipZJL07Vro7 Ate8Bfjya+wltGK9+XNUIHiumUKULW4KDx21+1NLAUeJ6PeW+DAkmJWF6QIDAQAB AoGBAJlNxenTQj6OfCl9FMR2jlMJjtMrtQT9InQEE7m3m7bLHeC+MCJOhmNVBjaM ZpthDORdxIZ6oCuOf6Z2+Dl35lntGFh5J7S34UP2BWzF1IyyQfySCNexGNHKT1G1 XKQtHmtc2gWWthEg+S6ciIyw2IGrrP2Rke81vYHExPrexf0hAkEA9Izb0MiYsMCB /jemLJB0Lb3Y/B8xjGjQFFBQT7bmwBVjvZWZVpnMnXi9sWGdgUpxsCuAIROXjZ40 IRZ2C9EouwJBAOPjPvV8Sgw4vaseOqlJvSq/C/pIFx6RVznDGlc8bRg7SgTPpjHG 4G+M3mVgpCX1a/EU1mB+fhiJ2LAZ/pTtY6sCQGaW9NwIWu3DRIVGCSMm0mYh/3X9 DAcwLSJoctiODQ1Fq9rreDE5QfpJnaJdJfsIJNtX1F+L3YceeBXtW0Ynz2MCQBI8 9KP274Is5FkWkUFNKnuKUK4WKOuEXEO+LpR+vIhs7k6WQ8nGDd4/mujoJBr5mkrw DPwqA3N5TMNDQVGv8gMCQQCaKGJgWYgvo3/milFfImbp+m7/Y3vCptarldXrYQWO AQjxwc71ZGBFDITYvdgJM1MTqc8xQek1FXn1vfpy2c6O -----END RSA PRIVATE KEY----- `)) * Rsa加密

func Sha1

func Sha1(str string) string

sha1加密

func Sha1Byte

func Sha1Byte(str string) []byte

sha1加密

func Sha256

func Sha256(str string) string

sha256加密

func Sha256Byte

func Sha256Byte(str string) []byte

sha256加密

func Sha512

func Sha512(str string) string

sha512加密

func Sha512Byte

func Sha512Byte(str string) []byte

sha512加密

Types

This section is empty.

Jump to

Keyboard shortcuts

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