Documentation ¶
Index ¶
- Variables
- func AbiCoder(argTypes []string, argValues []interface{}) ([]byte, error)
- func AbiCoderHex(argTypes []string, argValues []interface{}) (string, error)
- func AbiDecoder(argTypes []string, input []byte, argValues []interface{}) error
- func AbiDecoderWithReturnedValues(argTypes []string, input []byte) ([]interface{}, error)
- 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 PrivateKeyDecrypt(data, privateKey string) (string, error)
- func PrivateKeyEncrypt(data, privateKey string) (string, error)
- func PubkeyDecrypt(data, publicKey string) (string, error)
- func PubkeyEncrypt(data, publicKey string) (string, error)
- func RsaPrivateKeyFromBytes(privatekey []byte) (*rsa.PrivateKey, error)
- func RsaPubkeyFromBytes(publickey []byte) (*rsa.PublicKey, 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) PriKeyDecrypt(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PriKeyEncrypt(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PrivateKey() (*rsa.PrivateKey, error)
- func (rsas *RSASecurity) PubKeyDecrypt(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PubKeyEncrypt(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PublicKey() (*rsa.PublicKey, error)
- func (rsas *RSASecurity) SetPrivateKey(priStr string) error
- func (rsas *RSASecurity) SetPublicKey(pubStr string) 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 AbiCoderHex ¶
func AbiDecoder ¶
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 PrivateKeyDecrypt ¶
PrivateKeyDecrypt private decrypt
func PrivateKeyEncrypt ¶
PrivateKeyEncrypt private encrypt
func PubkeyDecrypt ¶
PubkeyDecrypt public decrypt
func PubkeyEncrypt ¶
PubkeyEncrypt public encrypt
func RsaPrivateKeyFromBytes ¶
func RsaPrivateKeyFromBytes(privatekey []byte) (*rsa.PrivateKey, error)
RsaPrivateKeyFromBytes get rsa private key from bytes
func RsaPubkeyFromBytes ¶
RsaPubkeyFromBytes get rsa public key from bytes
func SignMd5WithRsa ¶
SignMd5WithRsa Signed using the RSA With MD5 algorithm
func SignSha1WithRsa ¶
SignSha1WithRsa Sign with the RSA With SHA1 algorithm
func SignSha256WithRsa ¶
SignSha256WithRsa Sign with the RSA With SHA256 algorithm
func VerifySignMd5WithRsa ¶
VerifySignMd5WithRsa Verify signatures using RSA With MD 5
func VerifySignSha1WithRsa ¶
VerifySignSha1WithRsa Verify the signature using RSA With SHA 1
Types ¶
type RSASecurity ¶
type RSASecurity struct {
// contains filtered or unexported fields
}
func (*RSASecurity) PriKeyDecrypt ¶
func (rsas *RSASecurity) PriKeyDecrypt(input []byte) ([]byte, error)
PriKeyDecrypt private key decrypt
func (*RSASecurity) PriKeyEncrypt ¶
func (rsas *RSASecurity) PriKeyEncrypt(input []byte) ([]byte, error)
PriKeyEncrypt private key encrypt
func (*RSASecurity) PrivateKey ¶
func (rsas *RSASecurity) PrivateKey() (*rsa.PrivateKey, error)
PrivateKey *rsa.PrivateKey
func (*RSASecurity) PubKeyDecrypt ¶
func (rsas *RSASecurity) PubKeyDecrypt(input []byte) ([]byte, error)
PubKeyDecrypt pubkey decrypt
func (*RSASecurity) PubKeyEncrypt ¶
func (rsas *RSASecurity) PubKeyEncrypt(input []byte) ([]byte, error)
PubKeyEncrypt pubkey encrypt
func (*RSASecurity) PublicKey ¶
func (rsas *RSASecurity) PublicKey() (*rsa.PublicKey, error)
PublicKey *rsa.PublicKey
func (*RSASecurity) SetPrivateKey ¶
func (rsas *RSASecurity) SetPrivateKey(priStr string) error
SetPrivateKey set private key
func (*RSASecurity) SetPublicKey ¶
func (rsas *RSASecurity) SetPublicKey(pubStr string) error
SetPublicKey set public key
func (*RSASecurity) SignMd5WithRsa ¶
func (rsas *RSASecurity) SignMd5WithRsa(data string) (string, error)
SignMd5WithRsa PriKeySign private key sign by md5
func (*RSASecurity) SignSha1WithRsa ¶
func (rsas *RSASecurity) SignSha1WithRsa(data string) (string, error)
SignSha1WithRsa PriKeySign private key sign by sha1
func (*RSASecurity) SignSha256WithRsa ¶
func (rsas *RSASecurity) SignSha256WithRsa(data string) (string, error)
SignSha256WithRsa PriKeySign private key sign by sha256
func (*RSASecurity) VerifySignMd5WithRsa ¶
func (rsas *RSASecurity) VerifySignMd5WithRsa(data string, signData string) error
VerifySignMd5WithRsa PubKeyVerifySign public key verify sign by md5
func (*RSASecurity) VerifySignSha1WithRsa ¶
func (rsas *RSASecurity) VerifySignSha1WithRsa(data string, signData string) error
VerifySignSha1WithRsa PubKeyVerifySign public key verify sign by sha1
func (*RSASecurity) VerifySignSha256WithRsa ¶
func (rsas *RSASecurity) VerifySignSha256WithRsa(data string, signData string) error
VerifySignSha256WithRsa PubKeyVerifySign public key verify sign by sha256