Documentation ¶
Index ¶
- Variables
- func AesDecryptByECB(data, key []byte) []byte
- func AesDecryptByECBBase64(data, key string) string
- func AesEncryptByECB(data, key []byte) []byte
- func AesEncryptByECBBase64(data, key string) string
- func DesCBCDecrypter(data, key, iv []byte) []byte
- func DesCBCEncrypt(data, key, iv []byte) []byte
- func DesCFBDecrypter(data, key, iv []byte) []byte
- func DesCFBEncrypt(data, key, iv []byte) []byte
- func DesCTRDecrypter(data, key, iv []byte) []byte
- func DesCTREncrypt(data, key, iv []byte) []byte
- func DesECBDecrypter(data, key []byte) []byte
- func DesECBEncrypt(data, key []byte) []byte
- func DesOFBDecrypter(data, key, iv []byte) []byte
- func DesOFBEncrypt(data, key, iv []byte) []byte
- func GenerateRandomPass(length, numDigits, numSymbols int, noUpper, allowRepeat bool) (string, error)
- func PriKeyDecrypt(data, privateKey string) (string, error)
- func PriKeyEncrypt(data, privateKey string) (string, error)
- func PublicDecrypt(data, publicKey string) (string, error)
- func PublicEncrypt(data, publicKey string) (string, error)
- func SignMd5WithRsa(data string, privateKey string) (string, error)
- func SignSha1WithRsa(data string, privateKey string) (string, error)
- func SignSha256WithRsa(data string, privateKey string) (string, error)
- func VerifySignMd5WithRsa(data string, signData string, publicKey string) error
- func VerifySignSha1WithRsa(data string, signData string, publicKey string) error
- func VerifySignSha256WithRsa(data string, signData string, publicKey string) error
- type RSASecurity
- func (rsas *RSASecurity) GetPrivatekey() (*rsa.PrivateKey, error)
- func (rsas *RSASecurity) GetPublickey() (*rsa.PublicKey, error)
- func (rsas *RSASecurity) PriKeyDECRYPT(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PriKeyENCTYPT(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PubKeyDECRYPT(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PubKeyENCTYPT(input []byte) ([]byte, error)
- func (rsas *RSASecurity) SetPrivateKey(priStr string) (err error)
- func (rsas *RSASecurity) SetPublicKey(pubStr string) (err error)
- func (rsas *RSASecurity) SignMd5WithRsa(data string) (string, error)
- func (rsas *RSASecurity) SignSha1WithRsa(data string) (string, error)
- func (rsas *RSASecurity) SignSha256WithRsa(data string) (string, error)
- func (rsas *RSASecurity) VerifySignMd5WithRsa(data string, signData string) error
- func (rsas *RSASecurity) VerifySignSha1WithRsa(data string, signData string) error
- func (rsas *RSASecurity) VerifySignSha256WithRsa(data string, signData string) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrDataToLarge = errors.New("message too long for RSA public key size") ErrDataLen = errors.New("data length error") ErrDataBroken = errors.New("data broken, first byte is not zero") ErrKeyPairDismatch = errors.New("data is not encrypted by the private key") ErrDecryption = errors.New("decryption error") ErrPublicKey = errors.New("get public key error") ErrPrivateKey = errors.New("get private key error") )
var RSA = &RSASecurity{}
Functions ¶
func AesDecryptByECB ¶
AesDecryptByECB ---------------AES ECB解密-------------------- data: 密文数据 key: 密钥字符串 返回明文数据
func AesDecryptByECBBase64 ¶
AesDecryptByECBBase64 ---------------AES ECB解密 Base64-------------------- data: 密文数据 key: 密钥字符串 返回明文数据
func AesEncryptByECB ¶
AesEncryptByECB ---------------AES ECB加密-------------------- data: 明文数据 key: 密钥字符串 返回密文数据
func AesEncryptByECBBase64 ¶
AesEncryptByECBBase64 ---------------AES ECB加密 Base64-------------------- data: 明文数据 key: 密钥字符串 返回密文数据
func DesCBCDecrypter ¶
DesCBCDecrypter ---------------DES CBC解密-------------------- data: 密文数据 key: 密钥字符串 iv:iv向量 返回明文数据
func DesCBCEncrypt ¶
DesCBCEncrypt ---------------DES CBC加密-------------------- data: 明文数据 key: 密钥字符串 iv:iv向量 返回密文数据
func DesCFBDecrypter ¶
DesCFBDecrypter ---------------DES CFB解密-------------------- data: 密文数据 key: 密钥字符串 iv:iv向量 返回明文数据
func DesCFBEncrypt ¶
DesCFBEncrypt ---------------DES CFB加密-------------------- data: 明文数据 key: 密钥字符串 iv:iv向量 返回密文数据
func DesCTRDecrypter ¶
DesCTRDecrypter ---------------DES CTR解密-------------------- data: 密文数据 key: 密钥字符串 iv:iv向量 返回明文数据
func DesCTREncrypt ¶
DesCTREncrypt ---------------DES CTR加密-------------------- data: 明文数据 key: 密钥字符串 iv:iv向量 返回密文数据
func DesECBDecrypter ¶
DesECBDecrypter ---------------DES ECB解密-------------------- data: 密文数据 key: 密钥字符串 返回明文数据
func DesECBEncrypt ¶
DesECBEncrypt ---------------DES ECB加密-------------------- data: 明文数据 key: 密钥字符串 返回密文数据
func DesOFBDecrypter ¶
DesOFBDecrypter ---------------DES OFB解密-------------------- data: 密文数据 key: 密钥字符串 iv:iv向量 返回明文数据
func DesOFBEncrypt ¶
DesOFBEncrypt ---------------DES OFB加密-------------------- data: 明文数据 key: 密钥字符串 iv:iv向量 返回密文数据
func GenerateRandomPass ¶
func GenerateRandomPass(length, numDigits, numSymbols int, noUpper, allowRepeat bool) (string, error)
GenerateRandomPass 随机生成安全的密码
func SignMd5WithRsa ¶
使用RSAWithMD5算法签名
func SignSha1WithRsa ¶
使用RSAWithSHA1算法签名
func SignSha256WithRsa ¶
使用RSAWithSHA256算法签名
func VerifySignMd5WithRsa ¶
使用RSAWithMD5验证签名
func VerifySignSha1WithRsa ¶
使用RSAWithSHA1验证签名
Types ¶
type RSASecurity ¶
type RSASecurity struct {
// contains filtered or unexported fields
}
func (*RSASecurity) GetPrivatekey ¶
func (rsas *RSASecurity) GetPrivatekey() (*rsa.PrivateKey, error)
*rsa.PublicKey
func (*RSASecurity) GetPublickey ¶
func (rsas *RSASecurity) GetPublickey() (*rsa.PublicKey, error)
*rsa.PrivateKey
func (*RSASecurity) PriKeyDECRYPT ¶
func (rsas *RSASecurity) PriKeyDECRYPT(input []byte) ([]byte, error)
私钥解密
func (*RSASecurity) PriKeyENCTYPT ¶
func (rsas *RSASecurity) PriKeyENCTYPT(input []byte) ([]byte, error)
私钥加密
func (*RSASecurity) PubKeyDECRYPT ¶
func (rsas *RSASecurity) PubKeyDECRYPT(input []byte) ([]byte, error)
公钥解密
func (*RSASecurity) PubKeyENCTYPT ¶
func (rsas *RSASecurity) PubKeyENCTYPT(input []byte) ([]byte, error)
公钥加密
func (*RSASecurity) SetPrivateKey ¶
func (rsas *RSASecurity) SetPrivateKey(priStr string) (err error)
设置私钥
func (*RSASecurity) SetPublicKey ¶
func (rsas *RSASecurity) SetPublicKey(pubStr string) (err error)
设置公钥
func (*RSASecurity) SignMd5WithRsa ¶
func (rsas *RSASecurity) SignMd5WithRsa(data string) (string, error)
*
- 使用RSAWithMD5算法签名
func (*RSASecurity) SignSha1WithRsa ¶
func (rsas *RSASecurity) SignSha1WithRsa(data string) (string, error)
*
- 使用RSAWithSHA1算法签名
func (*RSASecurity) SignSha256WithRsa ¶
func (rsas *RSASecurity) SignSha256WithRsa(data string) (string, error)
*
- 使用RSAWithSHA256算法签名
func (*RSASecurity) VerifySignMd5WithRsa ¶
func (rsas *RSASecurity) VerifySignMd5WithRsa(data string, signData string) error
*
- 使用RSAWithMD5验证签名
func (*RSASecurity) VerifySignSha1WithRsa ¶
func (rsas *RSASecurity) VerifySignSha1WithRsa(data string, signData string) error
*
- 使用RSAWithSHA1验证签名
func (*RSASecurity) VerifySignSha256WithRsa ¶
func (rsas *RSASecurity) VerifySignSha256WithRsa(data string, signData string) error
*
- 使用RSAWithSHA256验证签名