Documentation
¶
Index ¶
- Constants
- Variables
- func CmpPbkdf2Passwd(password, salt, encrypted string, iter, keyLen int) bool
- func GenPbkdf2Passwd(password string, saltlen, iter, keyLen int) (string, string)
- type Crypto
- func (c *Crypto) Decrypt(src []byte) ([]byte, error)
- func (c *Crypto) DecryptStr(encryptedText string) (string, error)
- func (c *Crypto) DecryptStrWithKey(encryptedKey string, encryptedText string) (plainText string, err error)
- func (c *Crypto) DecryptWithKey(encryptedKey []byte, encryptedText []byte) (plainText []byte, err error)
- func (c *Crypto) Encrypt(src []byte) ([]byte, error)
- func (c *Crypto) EncryptStr(plainText string) (string, error)
- func (c *Crypto) EncryptStrWithKey(key []byte, plainText string) (encryptedKey string, encryptedText string, err error)
- func (c *Crypto) EncryptStrWithRandKey(plainText string) (encryptedKey string, encryptedText string, err error)
- func (c *Crypto) EncryptWithKey(key []byte, plainText []byte) (encryptedKey []byte, encryptedText []byte, err error)
Constants ¶
View Source
const ( // Pbkdf2SaltLen is default salt len for pbkdf2 Pbkdf2SaltLen = 16 // Pbkdf2IterTimes is default iterator times for pbkdf2 Pbkdf2IterTimes = 10000 //Pbkdf2keyLen is default rootKey length for pbkdf2 Pbkdf2keyLen = 40 )
Variables ¶
View Source
var ( // ErrAESTextSize ... ErrAESTextSize = errors.New("cipher text length is not a multiple of the block size") // ErrAESPadding ... ErrAESPadding = errors.New("cipher padding size error") // ErrInvalidKey ... ErrInvalidKey = errors.New("invalid key, it's length should more than 16") )
Functions ¶
func CmpPbkdf2Passwd ¶
CmpPbkdf2Passwd compare the password
Types ¶
type Crypto ¶
type Crypto struct {
// contains filtered or unexported fields
}
Crypto the crypto object
func (*Crypto) DecryptStr ¶
DecryptStr decrypt from an encrypted base64 string
func (*Crypto) DecryptStrWithKey ¶
func (c *Crypto) DecryptStrWithKey(encryptedKey string, encryptedText string) (plainText string, err error)
DecryptStrWithKey decrypt a string with encrypted work key
func (*Crypto) DecryptWithKey ¶
func (c *Crypto) DecryptWithKey(encryptedKey []byte, encryptedText []byte) (plainText []byte, err error)
DecryptStrWithKey decrypt a byte array with encrypted work key
func (*Crypto) EncryptStr ¶
EncryptStr encrypt a string
func (*Crypto) EncryptStrWithKey ¶
func (c *Crypto) EncryptStrWithKey(key []byte, plainText string) (encryptedKey string, encryptedText string, err error)
EncryptStrWithKey encrypt a byte array with a given work key encrypt work key using root key firstly then encrypt text using work key
Click to show internal directories.
Click to hide internal directories.