Documentation
¶
Overview ¶
@Author Eric @Date 2024/6/9 23:30:00 @Desc 加解密相关的处理
Index ¶
- func Aes256Decrypt(key []byte, cipherBytes []byte) ([]byte, error)
- func Aes256DecryptBase64(key []byte, ciphertext string) ([]byte, error)
- func Aes256Encrypt(key []byte, plaintext []byte) ([]byte, error)
- func Aes256EncryptBase64(key []byte, plaintext string) (string, error)
- func AesGCMDecrypt(key []byte, ciphertext []byte) ([]byte, error)
- func AesGCMEncrypt(key []byte, plaintext []byte) ([]byte, error)
- func GenerateCRC32(data []byte) string
- func GenerateRandomKey(length int) ([]byte, error)
- func HMACSHA256(key []byte, message string) (string, error)
- func MD5(data []byte) string
- func RSADecrypt(privKey *rsa.PrivateKey, ciphertext string) ([]byte, error)
- func RSAEncrypt(pubKey *rsa.PublicKey, plaintext []byte) (string, error)
- func SHA256(data []byte) string
- func XXTeaDecrypt(str, key string) string
- func XXTeaEncrypt(str, key string, expiry int) string
- func ZlibCompress(data []byte) ([]byte, error)
- func ZlibDecompress(data []byte) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aes256Decrypt ¶
Aes256Decrypt
@Description: AES256解密,CBC模式,PKCS7Padding,iv就是密钥 @param key 加密key @param ciphertext 密文 @return []byte 解密后数据 @return error
func Aes256DecryptBase64 ¶
Aes256DecryptBase64
@Description: AES256解密,CBC模式,PKCS7Padding,iv就是密钥 @param key 加密key @param ciphertext base64的密文 @return []byte 解密后数据 @return error
func Aes256Encrypt ¶
Aes256Encrypt
@Description: AES256加密,CBC模式,PKCS7Padding,iv就是密钥 @param key 加密key @param plaintext 原始数据 @return byte 返回加密后数据 @return error
func Aes256EncryptBase64 ¶
Aes256EncryptBase64
@Description: AES256加密,CBC模式,PKCS7Padding,iv就是密钥 @param key 加密key @param plaintext 原始数据 @return string 返回base64之后数据 @return error
func AesGCMDecrypt ¶
AesGCMDecrypt
@Description: AES-GCM 解密 @param key 加密key @param ciphertext 密文(包括nonce和ciphertext) @return []byte 返回解密后的数据 @return error
func AesGCMEncrypt ¶
AesGCMEncrypt
@Description: AES-GCM 加密 @param key 加密key @param plaintext 原始数据 @return []byte 返回加密后的数据(包括nonce和ciphertext) @return error
func GenerateRandomKey ¶
GenerateRandomKey
@Description: 生成指定长度的随机密钥,用于加密或签名等场景 @param length 密钥的长度(字节数) @return []byte 返回生成的随机密钥 @return error 如果生成失败,返回错误
func HMACSHA256 ¶
HMACSHA256
@Description: 生成基于密钥的 HMAC-SHA256 签名 @param key 签名密钥 @param message 签名内容 @return string 返回签名的十六进制字符串 @return error
func RSADecrypt ¶
func RSADecrypt(privKey *rsa.PrivateKey, ciphertext string) ([]byte, error)
RSADecrypt
@Description: RSA私钥解密 @param privKey 私钥 @param ciphertext base64加密的密文 @return []byte 返回解密后的数据 @return error
func RSAEncrypt ¶
RSAEncrypt
@Description: RSA公钥加密 @param pubKey 公钥 @param plaintext 原始数据 @return string 返回加密后的数据 @return error
func XXTeaEncrypt ¶
XXTeaEncrypt
@Description: 带过期时间的加密 @param str @param key @param expiry @return string
func ZlibCompress ¶
func ZlibDecompress ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.