Documentation ¶
Index ¶
- func HashSha256(src string) string
- func Md5(str string) string
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(data []byte) (b []byte, err error)
- func PasswordHash(password string) (string, error)
- func PasswordVerify(password, hash string) bool
- func RsaCreateKeys(keyLength int) (privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey, err error)
- func RsaCreateKeysPem(keyLength int) (privateKeyPem []byte, publicKeyPem []byte, err error)
- type AesEncryptor
- func (ae *AesEncryptor) Decrypt(data string, v interface{}) (err error)
- func (ae *AesEncryptor) DecryptByte(enData []byte, iv []byte) (deData []byte, err error)
- func (ae *AesEncryptor) DecryptString(data string) (string, error)
- func (ae *AesEncryptor) Encrypt(data interface{}) (string, error)
- func (ae *AesEncryptor) EncryptByte(rawData []byte, iv []byte) (enData []byte, err error)
- func (ae *AesEncryptor) EncryptString(data string) (enStr string, err error)
- func (ae *AesEncryptor) GetBlockSize() (size int, err error)
- func (ae *AesEncryptor) GetCipherBlock() (block cipher.Block, err error)
- func (ae *AesEncryptor) GetSecret() string
- func (ae *AesEncryptor) RandIv() (iv []byte, err error)
- func (ae *AesEncryptor) SetSecret(secret string) *AesEncryptor
- type RsaEncryptor
- func (r *RsaEncryptor) RsaBase64DecodeAndPrivateKeyDecrypt(cipherText string) (data []byte, err error)
- func (r *RsaEncryptor) RsaBase64DecodeAndPublicKeyVerifySign(data []byte, sign string) (err error)
- func (r *RsaEncryptor) RsaPrivateKeyDecrypt(cipher []byte) (data []byte, err error)
- func (r *RsaEncryptor) RsaPrivateKeySign(data []byte) (sign []byte, err error)
- func (r *RsaEncryptor) RsaPrivateKeySignAndBase64(data []byte) (sign string, err error)
- func (r *RsaEncryptor) RsaPublicKeyEncrypt(src []byte) (data []byte, err error)
- func (r *RsaEncryptor) RsaPublicKeyEncryptAndBase64(src []byte) (data string, err error)
- func (r *RsaEncryptor) RsaPublicKeyVerifySign(data []byte, sign []byte) (err error)
- func (r *RsaEncryptor) SetPrivateKey(privateKey []byte) (key *rsa.PrivateKey, err error)
- func (r *RsaEncryptor) SetPublicKey(publicKey []byte) (key *rsa.PublicKey, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashSha256 ¶
func PKCS7Padding ¶
func PKCS7UnPadding ¶
func PasswordHash ¶
func PasswordVerify ¶
func RsaCreateKeys ¶
Types ¶
type AesEncryptor ¶
type AesEncryptor struct {
// contains filtered or unexported fields
}
func NewAesEncryptor ¶
func NewAesEncryptor(secret string) (aesEncryptor *AesEncryptor)
func (*AesEncryptor) Decrypt ¶
func (ae *AesEncryptor) Decrypt(data string, v interface{}) (err error)
func (*AesEncryptor) DecryptByte ¶
func (ae *AesEncryptor) DecryptByte(enData []byte, iv []byte) (deData []byte, err error)
func (*AesEncryptor) DecryptString ¶
func (ae *AesEncryptor) DecryptString(data string) (string, error)
func (*AesEncryptor) Encrypt ¶
func (ae *AesEncryptor) Encrypt(data interface{}) (string, error)
func (*AesEncryptor) EncryptByte ¶
func (ae *AesEncryptor) EncryptByte(rawData []byte, iv []byte) (enData []byte, err error)
aes加密,填充秘钥key的16位,24,32分别对应AES-128, AES-192, or AES-256.
func (*AesEncryptor) EncryptString ¶
func (ae *AesEncryptor) EncryptString(data string) (enStr string, err error)
func (*AesEncryptor) GetBlockSize ¶
func (ae *AesEncryptor) GetBlockSize() (size int, err error)
func (*AesEncryptor) GetCipherBlock ¶
func (ae *AesEncryptor) GetCipherBlock() (block cipher.Block, err error)
func (*AesEncryptor) GetSecret ¶
func (ae *AesEncryptor) GetSecret() string
func (*AesEncryptor) RandIv ¶
func (ae *AesEncryptor) RandIv() (iv []byte, err error)
func (*AesEncryptor) SetSecret ¶
func (ae *AesEncryptor) SetSecret(secret string) *AesEncryptor
type RsaEncryptor ¶
type RsaEncryptor struct {
// contains filtered or unexported fields
}
func NewRsaEncryptor ¶
func NewRsaEncryptor() (encryptor *RsaEncryptor)
func (*RsaEncryptor) RsaBase64DecodeAndPrivateKeyDecrypt ¶
func (r *RsaEncryptor) RsaBase64DecodeAndPrivateKeyDecrypt(cipherText string) (data []byte, err error)
func (*RsaEncryptor) RsaBase64DecodeAndPublicKeyVerifySign ¶
func (r *RsaEncryptor) RsaBase64DecodeAndPublicKeyVerifySign(data []byte, sign string) (err error)
func (*RsaEncryptor) RsaPrivateKeyDecrypt ¶
func (r *RsaEncryptor) RsaPrivateKeyDecrypt(cipher []byte) (data []byte, err error)
func (*RsaEncryptor) RsaPrivateKeySign ¶
func (r *RsaEncryptor) RsaPrivateKeySign(data []byte) (sign []byte, err error)
func (*RsaEncryptor) RsaPrivateKeySignAndBase64 ¶
func (r *RsaEncryptor) RsaPrivateKeySignAndBase64(data []byte) (sign string, err error)
func (*RsaEncryptor) RsaPublicKeyEncrypt ¶
func (r *RsaEncryptor) RsaPublicKeyEncrypt(src []byte) (data []byte, err error)
func (*RsaEncryptor) RsaPublicKeyEncryptAndBase64 ¶
func (r *RsaEncryptor) RsaPublicKeyEncryptAndBase64(src []byte) (data string, err error)
func (*RsaEncryptor) RsaPublicKeyVerifySign ¶
func (r *RsaEncryptor) RsaPublicKeyVerifySign(data []byte, sign []byte) (err error)
func (*RsaEncryptor) SetPrivateKey ¶
func (r *RsaEncryptor) SetPrivateKey(privateKey []byte) (key *rsa.PrivateKey, err error)
func (*RsaEncryptor) SetPublicKey ¶
func (r *RsaEncryptor) SetPublicKey(publicKey []byte) (key *rsa.PublicKey, err error)
Click to show internal directories.
Click to hide internal directories.