Documentation
¶
Index ¶
- Constants
- Variables
- func AESDecryptByCBC(cipherTextBase64 string, keyBase, ivBase string) ([]byte, error)
- func AESDecryptByCCM(cipherTextBase64 string, keyBase, ivBase string) ([]byte, error)
- func AESDecryptByCTR(cipherTextBase64 string, keyBase, ivBase string) ([]byte, error)
- func AESDecryptByGCM(cipherTextBase64 string, keyBase, ivBase string) ([]byte, error)
- func AESEncryptByCBC(plainText []byte, keyBase, ivBase string) (string, error)
- func AESEncryptByCCM(plainText []byte, keyBase, ivBase string) (string, error)
- func AESEncryptByCTR(plainText []byte, keyBase, ivBase string) (string, error)
- func AESEncryptByGCM(plainText []byte, keyBase, ivBase string) (string, error)
- func CBCPkcs7Pad(data []byte, blockSize int) []byte
- func CBCPkcs7Unpad(data []byte) []byte
- func ECDSAGenerateECCCertificate(curve elliptic.Curve, subject pkix.Name) (keyPem, certPem []byte, err error)
- func ECDSAGenerateKeys(curve elliptic.Curve) (privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, err error)
- func GenAESKeyAndIv(KeyLen int, IvLen int) (keyBase, ivBase string, err error)
- func GenRandByte(btLen int) ([]byte, error)
- func GenRsaKey2Bt(btLen int) (privateKeyBt, publicKeyBt []byte, err error)
- func GenRsaKey2Str(btLen int) (privateKeyStr, publicKeyStr *string, err error)
- func HMACSha256(data string, key string) (hexStr string, baseStr string)
- func HMACSha512(data string, key string) (hexStr string, baseStr string)
- func ParseECDSAPrivateKeyFromPEM(privateKeyPEM string) (*ecdsa.PrivateKey, error)
- func ParseECDSAPublicKeyFromCert(certPEM string) (*ecdsa.PublicKey, error)
- func ParseRSAPrivateKey(pemData string) (*rsa.PrivateKey, error)
- func ParseRSAPublicKey(pemData string) (*rsa.PublicKey, error)
- func RSADecrypt(method hash.Hash, encryptedBase64 string, privateKey *rsa.PrivateKey) ([]byte, error)
- func RSADecryptBySha256(encryptedBase64 string, privateKey *rsa.PrivateKey) ([]byte, error)
- func RSADecryptBySha512(encryptedBase64 string, privateKey *rsa.PrivateKey) ([]byte, error)
- func RSAEncrypt(method hash.Hash, plainText []byte, publicKey *rsa.PublicKey) (string, error)
- func RSAEncryptBySha256(plainText []byte, publicKey *rsa.PublicKey) (string, error)
- func RSAEncryptBySha512(plainText []byte, publicKey *rsa.PublicKey) (string, error)
- func RSAGenerateKeys(bits int) (privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey, err error)
- func RSAParsePrivateKey2Bt(privateKey *rsa.PrivateKey) (prvKeyBt []byte, err error)
- func RSAParsePublicKey2Bt(publicKey *rsa.PublicKey) (pubKeyBt []byte, err error)
- func Sha256(data string) (hexStr string, baseStr string)
- func Sha512(data string) (hexStr string, baseStr string)
Constants ¶
View Source
const ( AES128KeyLen = 16 AES192KeyLen = 24 AES256KeyLen = 32 AESGCMIvLen = 12 AESCCMIvLen = 24 AEsCBCIvLen = 16 AESCTRIvLen = 16 )
Variables ¶
Functions ¶
func AESDecryptByCBC ¶
**AES-CBC 解密**
func AESDecryptByCCM ¶
**AES-CCM 解密**
func AESDecryptByCTR ¶
**AES-CTR 解密**
func AESDecryptByGCM ¶
**AES-GCM 解密**
func AESEncryptByCBC ¶
**AES-CBC 加密**
func AESEncryptByCCM ¶
**AES-CCM 加密**
func AESEncryptByCTR ¶
**AES-CTR 加密**
func AESEncryptByGCM ¶
**AES-GCM 加密**
func ECDSAGenerateECCCertificate ¶
func ECDSAGenerateECCCertificate(curve elliptic.Curve, subject pkix.Name) (keyPem, certPem []byte, err error)
note: 生成 ECC 证书
func ECDSAGenerateKeys ¶
func ECDSAGenerateKeys(curve elliptic.Curve) (privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, err error)
note: 生成 ECDSA 公私钥
func GenAESKeyAndIv ¶
func GenRandByte ¶
func GenRsaKey2Bt ¶
note: 生成 RSA 公私钥并解析到bt
func GenRsaKey2Str ¶
note: 生成 RSA 公私钥并解析到字符串
func ParseECDSAPrivateKeyFromPEM ¶
func ParseECDSAPrivateKeyFromPEM(privateKeyPEM string) (*ecdsa.PrivateKey, error)
**解析 ECDSA 公钥 **
func ParseRSAPrivateKey ¶
func ParseRSAPrivateKey(pemData string) (*rsa.PrivateKey, error)
解析 PEM 格式的私钥
func ParseRSAPublicKey ¶
解析 PEM 格式的公钥
func RSADecrypt ¶
func RSADecrypt(method hash.Hash, encryptedBase64 string, privateKey *rsa.PrivateKey) ([]byte, error)
RSA + SHA-512 进行解密
func RSADecryptBySha256 ¶ added in v0.0.16
func RSADecryptBySha256(encryptedBase64 string, privateKey *rsa.PrivateKey) ([]byte, error)
RSA + SHA-256 进行解密
func RSADecryptBySha512 ¶ added in v0.0.16
func RSADecryptBySha512(encryptedBase64 string, privateKey *rsa.PrivateKey) ([]byte, error)
RSA + SHA-512 进行解密
func RSAEncrypt ¶
RSA + SHA-512 进行加密
func RSAEncryptBySha256 ¶ added in v0.0.16
RSA + SHA-256 进行加密
func RSAEncryptBySha512 ¶ added in v0.0.16
RSA + SHA-512 进行加密
func RSAGenerateKeys ¶
note: 生成 RSA 公私钥
func RSAParsePrivateKey2Bt ¶
func RSAParsePrivateKey2Bt(privateKey *rsa.PrivateKey) (prvKeyBt []byte, err error)
note: 解析私钥到字节
func RSAParsePublicKey2Bt ¶
note: 解析公钥到字节
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.