Documentation ¶
Index ¶
- Constants
- Variables
- func AesCBCDecrypt(crypted, key []byte, iv []byte) ([]byte, error)
- func AesCBCEncrypt(origData, key []byte, iv []byte) ([]byte, error)
- func AesEcbDecrypt(crypted, key []byte) ([]byte, error)
- func AesEcbEncrypt(origData, key []byte) ([]byte, error)
- func DecodeBase64(cipherdata []byte) []byte
- func DecodeHex(hexdata []byte) []byte
- func DesDecrypt(crypted, key []byte) ([]byte, gerror.IError)
- func DesEncrypt(origData, key []byte) ([]byte, gerror.IError)
- func DoubleCBCDesDecrypt(ciphertext, key []byte) (origData []byte, err gerror.IError)
- func DoubleCBCDesDecryptBase64(crypted string, key []byte) ([]byte, gerror.IError)
- func DoubleCBCDesEncrypt(origData, key []byte) (ciphertext []byte, err gerror.IError)
- func DoubleDesDecrypt(crypted, key []byte) ([]byte, gerror.IError)
- func DoubleDesEncrypt(origData, key []byte) ([]byte, gerror.IError)
- func DoubleDesEncryptBase64(origData, key []byte) (string, gerror.IError)
- func EncodeBase64(origdata []byte) []byte
- func EncodeHex(origdata []byte) []byte
- func GenMd5(origData []byte) string
- func GenRsaKey(bits int) (priRes, pubRes string, err error)
- func GetFileMd5(filename string) (string, error)
- func GetMd5(origData []byte) []byte
- func GetRsaPrivateKey(filepath string) (pubKey *rsa.PrivateKey, err error)
- func GetRsaPrivateKeyByString(prikey string) (pubKey *rsa.PrivateKey, err error)
- func GetRsaPrivatePKCS8Key(filepath string) (pubKey *rsa.PrivateKey, err error)
- func GetRsaPublicKey(filePath string) (pubKey *rsa.PublicKey, err error)
- func GetRsaPublicKeyByString(pubkey string) (pubKey *rsa.PublicKey, err error)
- func Hash(algo int, hashbuf []byte) ([]byte, error)
- func HmacMd5(src, key string) string
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func NewECBEncrypter(b cipher.Block) cipher.BlockMode
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(plantText []byte) []byte
- func RsaDecryptBase64(decKey *rsa.PrivateKey, ciphertext string) (origData []byte, err error)
- func RsaEncryptBase64(encKey *rsa.PublicKey, origData []byte) (ciphertext string, err error)
- func RsaPrivKeyModules(priv *rsa.PrivateKey) int
- func RsaPubKeyModules(pub *rsa.PublicKey) int
- func RsaSignBase64(privSign *rsa.PrivateKey, req map[string]string) (ciphertext string, err error)
- func RsaSignSha1(privSign *rsa.PrivateKey, data []byte) (ciphertext []byte, err error)
- func RsaSignSha1Base64(privSign *rsa.PrivateKey, data []byte) (string, error)
- func RsaSignSha256(privSign *rsa.PrivateKey, data []byte) (ciphertext []byte, err error)
- func RsaVerifyBase64(cert *x509.Certificate, respMap map[string]string) (ok bool, err error)
- func RsaVerifySha1(pubVerify *rsa.PublicKey, data []byte, signResu []byte) (ok bool, err error)
- func RsaVerifySha1Base64(pubVerify *rsa.PublicKey, data string, signResu string) (ok bool, err error)
- func RsaVerifySha256Base64(pubVerify *rsa.PublicKey, data string, signResu string) (ok bool, err error)
- func TripleDesDecrypt(crypted, key []byte) ([]byte, gerror.IError)
- func TripleDesEncrypt(origData, key []byte) ([]byte, gerror.IError)
- func UnZlib(src []byte) ([]byte, error)
- func UnZlibBase64(src string) ([]byte, error)
- func UnionRsaSignBase64Url(privSign *rsa.PrivateKey, keysv map[string]string) (string, gerror.IError)
- func UnionRsaVerify(pubVerify *rsa.PublicKey, respMap map[string]string) (bool, gerror.IError)
- func VerifyHmacMd5(src, hmaced, key []byte) bool
- func VerifyMd5(origData []byte, desKey string) bool
- func ZeroPadding(ciphertext []byte, blockSize int) []byte
- func ZeroUnPadding(origData []byte) []byte
- func Zlib(src []byte) []byte
- func ZlibBase64(src []byte) string
- type CliCert
- type RSAKey
- func (r *RSAKey) DecryptPKCS1v15(cipherdata []byte) ([]byte, error)
- func (r *RSAKey) EncryptPKCS1v15(origdata []byte) ([]byte, error)
- func (r *RSAKey) GetModules() int
- func (r *RSAKey) Sign(algo int, signbuf []byte) ([]byte, error)
- func (r *RSAKey) Verfy(algo int, signbuf []byte, signature []byte) error
- type SvrCert
Constants ¶
View Source
const ( //证书RSA FILE_CERT_CER = "CER" FILE_CERT_PFX = "PFX" //公私钥 FILE_RSA_PEM_PUB = "PEM-RSA-PUB" FILE_RSA_PEM_PRIV = "PEM-RSA-PRIV" )
View Source
const ( UnknownSignatureAlgorithm int = iota MD2WithRSA MD5WithRSA SHA1WithRSA SHA256WithRSA SHA384WithRSA SHA512WithRSA DSAWithSHA1 DSAWithSHA256 ECDSAWithSHA1 ECDSAWithSHA256 ECDSAWithSHA384 ECDSAWithSHA512 )
Variables ¶
View Source
var IV = []byte{0, 0, 0, 0, 0, 0, 0, 0}
Functions ¶
func AesEcbDecrypt ¶
func AesEcbEncrypt ¶
func DecodeBase64 ¶
func DesEncrypt ¶
var IV = []byte("01234567")
func DoubleCBCDesDecrypt ¶
func DoubleCBCDesEncrypt ¶
func DoubleDesEncryptBase64 ¶
func EncodeBase64 ¶
func GetFileMd5 ¶
func GetRsaPrivateKey ¶
func GetRsaPrivateKey(filepath string) (pubKey *rsa.PrivateKey, err error)
获取私钥
func GetRsaPrivateKeyByString ¶
func GetRsaPrivateKeyByString(prikey string) (pubKey *rsa.PrivateKey, err error)
func GetRsaPrivatePKCS8Key ¶
func GetRsaPrivatePKCS8Key(filepath string) (pubKey *rsa.PrivateKey, err error)
func GetRsaPublicKey ¶
获取公钥
func GetRsaPublicKeyByString ¶
func NewECBDecrypter ¶
NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given cipher.Block.
func NewECBEncrypter ¶
NewECBEncrypter returns a BlockMode which encrypts in electronic code book mode, using the given cipher.Block.
func PKCS5Padding ¶
func PKCS5UnPadding ¶
func PKCS7Padding ¶
func PKCS7UnPadding ¶
func RsaDecryptBase64 ¶
func RsaDecryptBase64(decKey *rsa.PrivateKey, ciphertext string) (origData []byte, err error)
解密
func RsaEncryptBase64 ¶
RSA 报文加密
func RsaPrivKeyModules ¶
func RsaPrivKeyModules(priv *rsa.PrivateKey) int
func RsaPubKeyModules ¶
func RsaSignBase64 ¶
func RsaSignSha1 ¶
func RsaSignSha1(privSign *rsa.PrivateKey, data []byte) (ciphertext []byte, err error)
func RsaSignSha1Base64 ¶
func RsaSignSha1Base64(privSign *rsa.PrivateKey, data []byte) (string, error)
func RsaSignSha256 ¶
func RsaSignSha256(privSign *rsa.PrivateKey, data []byte) (ciphertext []byte, err error)
func RsaVerifyBase64 ¶
func RsaVerifySha1 ¶
func RsaVerifySha1Base64 ¶
func RsaVerifySha256Base64 ¶
func UnZlibBase64 ¶
func UnionRsaSignBase64Url ¶
func UnionRsaVerify ¶
func VerifyHmacMd5 ¶
func ZeroPadding ¶
func ZeroUnPadding ¶
func ZlibBase64 ¶
Types ¶
type CliCert ¶
type CliCert struct { KeyType string `json:"key_type"` KeyFile string `json:"key_file"` SerialNumber string `json:"serial_number"` X509Cert *x509.Certificate PublicKey interface{} PublicKeyAlgorithm x509.PublicKeyAlgorithm }
func NewCliCert ¶
func (*CliCert) EncryptPKCS1v15 ¶
签名公钥加密:
type RSAKey ¶
type RSAKey struct { KeyType string `json:"key_type"` KeyFile string `json:"key_file"` PublicKey *rsa.PublicKey PrivateKey *rsa.PrivateKey Modules int }
func (*RSAKey) DecryptPKCS1v15 ¶
func (*RSAKey) GetModules ¶
type SvrCert ¶
type SvrCert struct { KeyType string `json:"key_type"` KeyFile string `json:"key_file"` CertFile string `json:"cert_file"` SerialNumber string `json:"serial_number"` X509Cert *x509.Certificate PrivateKey interface{} PublicKey interface{} }
func NewSvrCert ¶
func (*SvrCert) DecryptPKCS1v15 ¶
私钥解密
func (*SvrCert) EncryptPKCS1v15 ¶
公钥加密:
Source Files ¶
Click to show internal directories.
Click to hide internal directories.