Documentation ¶
Index ¶
- func AES(key []byte) (cipher.Block, error)
- func DES(key []byte) (cipher.Block, error)
- func DecryptCBC(block cipher.Block, iv []byte, src []byte, dst []byte) error
- func DecryptCFB(block cipher.Block, iv []byte, src []byte, dst []byte) error
- func DecryptCTR(block cipher.Block, iv []byte, src []byte, dst []byte) error
- func DecryptECB(block cipher.Block, _ []byte, src []byte, dst []byte) error
- func DecryptOFB(block cipher.Block, iv []byte, src []byte, dst []byte) error
- func EncryptCBC(block cipher.Block, iv []byte, src []byte, dst []byte) error
- func EncryptCFB(block cipher.Block, iv []byte, src []byte, dst []byte) error
- func EncryptCTR(block cipher.Block, iv []byte, src []byte, dst []byte) error
- func EncryptECB(block cipher.Block, _ []byte, src []byte, dst []byte) error
- func EncryptOFB(block cipher.Block, iv []byte, src []byte, dst []byte) error
- func MD5() hash.Hash
- func PaddingNone(data []byte, _ int) []byte
- func PaddingPKCS5(data []byte, blockSize int) []byte
- func PaddingPKCS7(data []byte, blockSize int) []byte
- func PaddingZero(data []byte, blockSize int) []byte
- func SHA1() hash.Hash
- func SHA224() hash.Hash
- func SHA256() hash.Hash
- func SHA384() hash.Hash
- func SHA512() hash.Hash
- func TripleDES(key []byte) (cipher.Block, error)
- func UnPaddingNone(data []byte, _ int) ([]byte, error)
- func UnPaddingPKCS5(data []byte, blockSize int) ([]byte, error)
- func UnPaddingPKCS7(data []byte, blockSize int) ([]byte, error)
- func UnPaddingZero(data []byte, blockSize int) ([]byte, error)
- type Bytes
- type Cipher
- type DecryptMode
- type Decrypter
- type EncryptMode
- type Encrypter
- type Hash
- type Hasher
- type Padding
- type UnPadding
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptCBC ¶
DecryptCBC is cbc decrypting mode.
func DecryptCFB ¶
DecryptCFB is cfb decrypting mode.
func DecryptCTR ¶
DecryptCTR is ctr decrypting mode.
func DecryptECB ¶
DecryptECB is ecb decrypting mode.
func DecryptOFB ¶
DecryptOFB is ofb decrypting mode.
func EncryptCBC ¶
EncryptCBC is cbc encrypting mode.
func EncryptCFB ¶
EncryptCFB is cfb encrypting mode.
func EncryptCTR ¶
EncryptCTR is ctr encrypting mode.
func EncryptECB ¶
EncryptECB is ecb encrypting mode.
func EncryptOFB ¶
EncryptOFB is ofb encrypting mode.
func PaddingNone ¶
PaddingNone won't padding anything to data.
func PaddingPKCS5 ¶
PaddingPKCS5 paddings data using pkcs5.
func PaddingPKCS7 ¶
PaddingPKCS7 paddings data using pkcs7.
func PaddingZero ¶
PaddingZero paddings zero to data.
func UnPaddingNone ¶
UnPaddingNone won't unPadding anything from data.
func UnPaddingPKCS5 ¶
UnPaddingPKCS5 unPaddings data using pkcs5.
func UnPaddingPKCS7 ¶
UnPaddingPKCS7 unPaddings data using pkcs7.
Types ¶
type Bytes ¶
type Bytes []byte
Bytes is an alias of []byte.
func ParseBase64 ¶
ParseBase64 uses base64 to parse string to Bytes.
func RandomBytes ¶
RandomBytes returns a byte slice filled with random byte. It usually used to generate an iv and install iv to crypted data. For example, you use this method to generate a byte slice and pass it to encrypter as iv. After encrypting, you append this iv slice encoded to hex or base64 to crypted slice as they are one part. When you need to decrypt data, parse iv from the "crypted" slice including raw-crypted slice and iv slice first. Then you can pass this iv to decrypter and decrypt data as usual. However, you should know that the crypted data of the same plain data will be different every time because of different ivs.
type DecryptMode ¶
DecryptMode is a function using one mode to encrypt src to dst.
type Decrypter ¶
type Decrypter struct {
// contains filtered or unexported fields
}
Decrypter decrypts data from bytes, hex, and base64.
func NewDecrypter ¶
func NewDecrypter(cipher Cipher, key []byte, mode DecryptMode, iv []byte, unPadding UnPadding) Decrypter
NewDecrypter returns a new decrypter.
func (Decrypter) DecryptBase64 ¶
DecryptBase64 decrypts base64 in hex to bytes.
type EncryptMode ¶
EncryptMode is a function using one mode to encrypt src to dst.
type Encrypter ¶
type Encrypter struct {
// contains filtered or unexported fields
}
Encrypter encrypts data to bytes, hex, and base64.
func NewEncrypter ¶
func NewEncrypter(cipher Cipher, key []byte, mode EncryptMode, iv []byte, padding Padding) Encrypter
NewEncrypter returns a new encrypter.
func (Encrypter) EncryptBase64 ¶
EncryptBase64 encrypts data to string in base64.
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher hashes data with inside hash.