Documentation ¶
Overview ¶
reference:
https://blog.csdn.net/wade3015/article/details/84454836
reference:
https://gist.github.com/temoto/5052503
reference:
https://github.com/SimonWaldherr/golang-examples/blob/master/advanced/aesChacha20Poly1305.go
reference:
https://github.com/SimonWaldherr/golang-examples/blob/master/advanced/aesgcm.go
Index ¶
- Variables
- func GenerateIV(size int) (string, error)
- func GenerateKey(size int) (string, error)
- func GenerateNonce(size int) (string, error)
- func PaddingKey(key []byte, expectedLength int) []byte
- func RandomString(length int) string
- type Aes
- type Base32Encoding
- type Base64Encoding
- type CBC
- func (a *CBC) Decrypt(cipherbytes, key []byte) (plainbytes []byte, err error)
- func (a *CBC) DecryptString(ciphertext, secret string) (plaintext string, err error)
- func (a *CBC) Encrypt(plainbytes, key []byte) (cipherbytes []byte, err error)
- func (a *CBC) EncryptString(plaintext, secret string) (ciphertext string, err error)
- type CFB
- func (a *CFB) Decrypt(cipherbytes, key []byte) (plainbytes []byte, err error)
- func (a *CFB) DecryptString(ciphertext, secret string) (plaintext string, err error)
- func (a *CFB) Encrypt(plainbytes, key []byte) (cipherbytes []byte, err error)
- func (a *CFB) EncryptString(plaintext, secret string) (ciphertext string, err error)
- type Chacha20Poly1305
- func (a *Chacha20Poly1305) Decrypt(cipherbytes, key []byte) (plainbytes []byte, err error)
- func (a *Chacha20Poly1305) DecryptString(ciphertext, secret string) (plaintext string, err error)
- func (a *Chacha20Poly1305) Encrypt(plainbytes, key []byte) (cipherbytes []byte, err error)
- func (a *Chacha20Poly1305) EncryptString(plaintext, secret string) (ciphertext string, err error)
- type Encoding
- type GCM
- func (a *GCM) Decrypt(cipherbytes, key []byte) (plainbytes []byte, err error)
- func (a *GCM) DecryptString(ciphertext, secret string) (plaintext string, err error)
- func (a *GCM) Encrypt(plainbytes, key []byte) (cipherbytes []byte, err error)
- func (a *GCM) EncryptString(plaintext, secret string) (ciphertext string, err error)
- type HexEncoding
- type PCKS7Padding
- type Padding
- type ZerosPadding
Constants ¶
This section is empty.
Variables ¶
View Source
var SIZE = []int{128, 192, 256}
Functions ¶
func GenerateIV ¶
func GenerateKey ¶
func GenerateNonce ¶
func PaddingKey ¶ added in v1.0.5
func RandomString ¶
Types ¶
type Aes ¶
func (*Aes) GenerateIV ¶
func (*Aes) GenerateKey ¶
func (*Aes) GenerateNonce ¶
func (*Aes) GetNonce ¶
reference: https://qa.1r1g.cn/crypto/ask/4985151/
type Base32Encoding ¶
type Base32Encoding struct{}
func (*Base32Encoding) DecodeString ¶
func (e *Base32Encoding) DecodeString(s string) ([]byte, error)
func (*Base32Encoding) EncodeToString ¶
func (e *Base32Encoding) EncodeToString(src []byte) string
type Base64Encoding ¶
type Base64Encoding struct{}
func (*Base64Encoding) DecodeString ¶
func (e *Base64Encoding) DecodeString(s string) ([]byte, error)
func (*Base64Encoding) EncodeToString ¶
func (e *Base64Encoding) EncodeToString(src []byte) string
type CBC ¶
func (*CBC) DecryptString ¶
type Chacha20Poly1305 ¶
type Chacha20Poly1305 struct {
Aes
}
func NewChacha20Poly1305 ¶
func NewChacha20Poly1305(encoding Encoding, iv []byte) (*Chacha20Poly1305, error)
func (*Chacha20Poly1305) Decrypt ¶
func (a *Chacha20Poly1305) Decrypt(cipherbytes, key []byte) (plainbytes []byte, err error)
func (*Chacha20Poly1305) DecryptString ¶
func (a *Chacha20Poly1305) DecryptString(ciphertext, secret string) (plaintext string, err error)
func (*Chacha20Poly1305) Encrypt ¶
func (a *Chacha20Poly1305) Encrypt(plainbytes, key []byte) (cipherbytes []byte, err error)
func (*Chacha20Poly1305) EncryptString ¶
func (a *Chacha20Poly1305) EncryptString(plaintext, secret string) (ciphertext string, err error)
type HexEncoding ¶
type HexEncoding struct{}
func (*HexEncoding) DecodeString ¶
func (e *HexEncoding) DecodeString(s string) ([]byte, error)
func (*HexEncoding) EncodeToString ¶
func (e *HexEncoding) EncodeToString(src []byte) string
type PCKS7Padding ¶
type PCKS7Padding struct{}
type ZerosPadding ¶
type ZerosPadding struct{}
Click to show internal directories.
Click to hide internal directories.