Documentation ¶
Index ¶
- func AESCBCDecrypt(dst, cipherText, key, iv []byte) (int, error)
- func AESCBCDecryptLen[T typez.StrOrBytes](cipherText T) int
- func AESCBCEncrypt(dst, plainText, key, iv []byte) error
- func AESCBCEncryptLen[T typez.StrOrBytes](plainText T) int
- func AESGCMDecrypt(dst, cipherText, key, nonce, additionalData []byte) error
- func AESGCMDecryptLen[T typez.StrOrBytes](cipherText T) int
- func AESGCMEncrypt(dst, plainText, key, nonce, additionalData []byte) error
- func AESGCMEncryptLen[T typez.StrOrBytes](plainText T) int
- func Decrypt[T, E typez.StrOrBytes](cipherText T, secret E) ([]byte, error)
- func DecryptStreamTo[E typez.StrOrBytes](out io.Writer, stream io.Reader, secret E) error
- func Encrypt[T, E typez.StrOrBytes](plainText T, secret E) ([]byte, error)
- func EncryptStreamTo[E typez.StrOrBytes](out io.Writer, stream io.Reader, secret E) error
- func GCMDecrypt[T, E, D typez.StrOrBytes](cipherText T, secret E, additionalData D) ([]byte, error)
- func GCMEncrypt[T, E, D typez.StrOrBytes](plainText T, secret E, additionalData D) ([]byte, error)
- func PKCS5Padding(data []byte) ([]byte, error)
- func PKCS5UnPadding(data []byte) ([]byte, error)
- func PKCS7Padding(data []byte, blockSize int) ([]byte, error)
- func PKCS7UnPadding(data []byte, blockSize int) ([]byte, error)
- func SaltBySecretCBCDecrypt[E typez.StrOrBytes](cipherText []byte, secret E, reuseCipherText bool) ([]byte, error)
- func SaltBySecretCBCEncrypt[T, E typez.StrOrBytes](plainText T, secret E) ([]byte, error)
- func SaltBySecretGCMDecrypt[E, D typez.StrOrBytes](cipherText []byte, secret E, additionalData D, reuseCipherText bool) ([]byte, error)
- func SaltBySecretGCMEncrypt[T, E, D typez.StrOrBytes](plainText T, secret E, additionalData D) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESCBCDecrypt ¶ added in v0.0.2
AESCBCDecrypt decrypts encryptText with key and iv key length must be 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256. iv length must be 16 bytes, iv should be random to ensure safety dst could reuse encryptText memory
func AESCBCDecryptLen ¶ added in v0.0.2
func AESCBCDecryptLen[T typez.StrOrBytes](cipherText T) int
AESCBCDecryptLen returns the length of the decrypted data
func AESCBCEncrypt ¶ added in v0.0.2
AESCBCEncrypt encrypts plainText with key and iv key length must be 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256. iv length must be 16 bytes, iv should be random to ensure safety plainText could pre grow padding length, so dst could reuse plainText memory
func AESCBCEncryptLen ¶ added in v0.0.2
func AESCBCEncryptLen[T typez.StrOrBytes](plainText T) int
AESCBCEncryptLen returns the length of the encrypted data
func AESGCMDecrypt ¶ added in v0.0.2
AESGCMDecrypt decrypts encryptText with key and additionalData key length must be 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256. dst could reuse encryptText memory, like encryptText[:AESGCMDecryptLen(encryptText)]
func AESGCMDecryptLen ¶ added in v0.0.2
func AESGCMDecryptLen[T typez.StrOrBytes](cipherText T) int
AESGCMDecryptLen returns the length of the decrypted data
func AESGCMEncrypt ¶ added in v0.0.2
AESGCMEncrypt encrypts plainText with key and additionalData key length must be 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256. plainText could pre grow tagSize(default 16) so dst could reuse plainText memory
func AESGCMEncryptLen ¶ added in v0.0.2
func AESGCMEncryptLen[T typez.StrOrBytes](plainText T) int
AESGCMEncryptLen returns the length of the encrypted data
func Decrypt ¶
func Decrypt[T, E typez.StrOrBytes](cipherText T, secret E) ([]byte, error)
Decrypt decrypts cipherText with secret (openssl aes-256-cbc implementation).
func DecryptStreamTo ¶
DecryptStreamTo decrypts stream to out with secret
func Encrypt ¶
func Encrypt[T, E typez.StrOrBytes](plainText T, secret E) ([]byte, error)
Encrypt encrypts plainText with secret (openssl aes-256-cbc implementation).
func EncryptStreamTo ¶
EncryptStreamTo encrypts stream to out with secret
func GCMDecrypt ¶ added in v0.0.2
func GCMDecrypt[T, E, D typez.StrOrBytes](cipherText T, secret E, additionalData D) ([]byte, error)
GCMDecrypt decrypts cipherText with secret and additionalData
func GCMEncrypt ¶ added in v0.0.2
func GCMEncrypt[T, E, D typez.StrOrBytes](plainText T, secret E, additionalData D) ([]byte, error)
GCMEncrypt encrypts plainText with secret and additionalData
func PKCS5Padding ¶
PKCS5Padding adds padding to the input data according to the PKCS#5 standard
func PKCS5UnPadding ¶
PKCS5UnPadding removes padding from the input data according to the PKCS#5 standard
func PKCS7Padding ¶
PKCS7Padding adds padding to the input data according to the PKCS#7 standard
func PKCS7UnPadding ¶
PKCS7UnPadding removes padding from the input data according to the PKCS#7 standard
func SaltBySecretCBCDecrypt ¶ added in v0.0.8
func SaltBySecretCBCDecrypt[E typez.StrOrBytes](cipherText []byte, secret E, reuseCipherText bool) ([]byte, error)
SaltBySecretCBCDecrypt
func SaltBySecretCBCEncrypt ¶ added in v0.0.8
func SaltBySecretCBCEncrypt[T, E typez.StrOrBytes](plainText T, secret E) ([]byte, error)
SaltBySecretCBCEncrypt
func SaltBySecretGCMDecrypt ¶ added in v0.0.8
func SaltBySecretGCMDecrypt[E, D typez.StrOrBytes](cipherText []byte, secret E, additionalData D, reuseCipherText bool) ([]byte, error)
SaltBySecretGCMDecrypt
func SaltBySecretGCMEncrypt ¶ added in v0.0.8
func SaltBySecretGCMEncrypt[T, E, D typez.StrOrBytes](plainText T, secret E, additionalData D) ([]byte, error)
SaltBySecretGCMEncrypt
Types ¶
This section is empty.