Documentation ¶
Overview ¶
Package secutil provide some security utils
Index ¶
- Constants
- Variables
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) ([]byte, error)
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) ([]byte, error)
- type AesCrypt
- func (p *AesCrypt) Config(fn func(c *CryptConfig)) *AesCrypt
- func (p *AesCrypt) Decrypt(enc []byte) ([]byte, error)
- func (p *AesCrypt) DecryptString(enc string) (string, error)
- func (p *AesCrypt) Encrypt(src []byte) ([]byte, error)
- func (p *AesCrypt) EncryptString(src string) (string, error)
- func (p *AesCrypt) Init() error
- type CryptConfig
Constants ¶
View Source
const ( CryptAes128CBC = "aes-128-cbc" CryptAes256CBC = "aes-256-cbc" )
aes methods
View Source
const ( PadTypeNone uint8 = iota PadTypeZeros PadTypePKCS5 PadTypePKCS7 )
padding type for encoding contents.
Variables ¶
View Source
var ErrUnPadding = errors.New("un-padding decrypted data fail")
ErrUnPadding error
Functions ¶
func PKCS5Padding ¶
PKCS5Padding input data
func PKCS5UnPadding ¶
PKCS5UnPadding input data
func PKCS7Padding ¶
PKCS7Padding input data
func PKCS7UnPadding ¶
PKCS7UnPadding input data
Types ¶
type AesCrypt ¶
type AesCrypt struct { CryptConfig // contains filtered or unexported fields }
AesCrypt struct
func (*AesCrypt) Config ¶
func (p *AesCrypt) Config(fn func(c *CryptConfig)) *AesCrypt
Config crypt instance
func (*AesCrypt) DecryptString ¶
DecryptString to source string. return error on fail.
func (*AesCrypt) EncryptString ¶
EncryptString to encoded string. return error on fail.
type CryptConfig ¶
type CryptConfig struct { Key string // IV string, length must be equals to cipher.Block.BlockSize() IV string // Method name. eg: CryptAes256CBC Method string // PadType for padding string. PadType uint8 Encoder byteutil.BytesEncoder }
CryptConfig struct
Click to show internal directories.
Click to hide internal directories.