Documentation ¶
Index ¶
- func AES128CBCDecrypt(src string, sKey string, ivParameter string) string
- func AES128CBCEncrypt(src string, sKey string, ivParameter string) string
- func Aes128Decrypt(crypted, key []byte, IV []byte) ([]byte, error)
- func Aes128Encrypt(origData, key []byte, IV []byte) ([]byte, error)
- func Base64Decode(str string) string
- func Base64Encode(str string) string
- func Base64RawDecode(str string) string
- func Base64RawEncode(str string) string
- func Base64StdDecode(str string) string
- func Base64StdEncode(str string) string
- func CalToken(redirectURL, partnerKey string) (result string)
- func DecryptAeAdAes256Gcm(ciphertext, nonce, associatedData string, aesKey []byte) string
- func DesDecryptCBC(src, key string) string
- func DesDecryptECB(src, key string) string
- func DesEncryptCBC(src, key string) string
- func DesEncryptECB(src, key string) string
- func HMACSHA256(data []byte, key []byte) []byte
- func Hmac(str string, key string) string
- func HmacHex(str string, key string) string
- func HmacSHA1(str string, key string) string
- func Md5(str string) string
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func Rsa2(origData string, block []byte) (sign string)
- func RsaDecrypt(data string, privateKey string) string
- func RsaDecryptByte(ciphertext []byte, privateKey string) ([]byte, error)
- func RsaEncrypt(data string, publicKey string) string
- func RsaEncryptByte(data []byte, publicKey string) ([]byte, error)
- func Sha1(str string) string
- func Sha1Byte(str string) []byte
- func Sha256(str string) string
- func Sha256Byte(str string) []byte
- func Sha512(str string) string
- func Sha512Byte(str string) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AES128CBCDecrypt ¶
解密 参数src:加密结果base64的 参数sKey:加密密钥,非base64的 参数ivParameter:加密向量,非base64的 返回值:原始文本内容
func AES128CBCEncrypt ¶
加密 参数src:原始文本 参数sKey:加密密钥,非base64的 参数ivParameter:加密向量,非base64的 返回值:base64的加密结果
func DecryptAeAdAes256Gcm ¶ added in v0.0.14
AEAD_AES_256_GCM 解密
func DesDecryptCBC ¶
CBC解密 参数src:要解密的数据 参数key:密钥,长度必须是8位数不能超过 返回值:解密后的数据
func DesDecryptECB ¶
ECB解密 参数src:要解密的数据 参数key:密钥,长度必须是8位数不能超过 返回值:解密后的数据
func DesEncryptCBC ¶
CBC加密 参数src:要加密的数据 参数key:密钥,长度必须是8位数不能超过 返回值:加密后的数据
func DesEncryptECB ¶
ECB加密 参数src:要加密的数据 参数key:密钥,长度必须是8位数不能超过 返回值:加密后的数据
func RsaDecrypt ¶
Rsa解密 参数data:要解密的数据 privateKey:私钥 返回值:解密后数据
func RsaDecryptByte ¶
Rsa解密
func RsaEncrypt ¶
Rsa加密 参数data:要加密的数据 参数publicKey:公钥 返回值:加密后数据
func RsaEncryptByte ¶
* 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加密
Types ¶
This section is empty.