Documentation ¶
Index ¶
- Constants
- func CipherModeNames() []string
- func EncryptionMethodNames() []string
- func PKCS7Padding(src []byte, blockSize int) []byte
- func PKCS7Unpadding(src []byte) []byte
- func PaddingNames() []string
- func PrintConfig(w io.Writer, cfgset map[string]Config, insecure bool)
- func RandBytes(n int) (b []byte, err error)
- func SaltDecodeRule(src []byte, salt []byte, has bool) (src_, salt_ []byte)
- func SaltEncodeRule(src []byte, salt []byte, has bool) (src_ []byte)
- func StrConvNames() []string
- type BlockSize_AES
- type BlockSize_DES
- type Cipher
- type CipherMode
- type Config
- type ConfigBlock
- type ConfigCipher
- type ConfigPadding
- type ConfigStrConv
- type Decoder
- type Encoder
- type EncryptionMethod
- type Machine
- func (machine *Machine) Decode(src []byte) ([]byte, error)
- func (machine *Machine) DecodeDetail(src []byte, callback ...func(map[string]interface{})) (dst []byte, err error)
- func (machine *Machine) Encode(src []byte) ([]byte, error)
- func (machine *Machine) EncodeDetail(src []byte, callback ...func(map[string]interface{})) (dst []byte, err error)
- type MachineOption
- type NoneEncripter
- type Padding
- type Salt
- type ScopeSalt
- type StrConv
Constants ¶
const ( BlockSize_AES128 BlockSize_AES = 128 / 8 BlockSize_AES192 = 192 / 8 BlockSize_AES256 = 256 / 8 )
Variables ¶
This section is empty.
Functions ¶
func CipherModeNames ¶
func CipherModeNames() []string
CipherModeNames returns a list of possible string values of CipherMode.
func EncryptionMethodNames ¶
func EncryptionMethodNames() []string
EncryptionMethodNames returns a list of possible string values of EncryptionMethod.
func PKCS7Padding ¶
func PKCS7Unpadding ¶
func PaddingNames ¶
func PaddingNames() []string
PaddingNames returns a list of possible string values of Padding.
func StrConvNames ¶
func StrConvNames() []string
StrConvNames returns a list of possible string values of StrConv.
Types ¶
type BlockSize_AES ¶
type BlockSize_AES int
type CipherMode ¶
type CipherMode int
ENUM( NONE CBC GCM )
const ( // CipherModeNONE is a CipherMode of type NONE. CipherModeNONE CipherMode = iota // CipherModeCBC is a CipherMode of type CBC. CipherModeCBC // CipherModeGCM is a CipherMode of type GCM. CipherModeGCM )
func ParseCipherMode ¶
func ParseCipherMode(name string) (CipherMode, error)
ParseCipherMode attempts to convert a string to a CipherMode.
func (CipherMode) CipherFactory ¶
func (CipherMode) String ¶
func (x CipherMode) String() string
String implements the Stringer interface.
type Config ¶
type Config struct { ConfigBlock `yaml:",inline"` ConfigCipher `yaml:",inline"` ConfigPadding `yaml:",inline"` ConfigStrConv `yaml:",inline"` }
blockMethod: aes # NONE, AES, DES blockSize: 128 # NONE: default(1), AES: 128|192|256, DES: 64 blockKey: secret # (base64 string) cipherMode: gcm # NONE: NONE|AES|DES , GCM: AES, CBC: NONE|AES|DES cipherSalt: null # NULL, (base64 string) padding: PKCS # NONE: AES+GCM, PKCS: AES+NONE|AES+CBC|DES+NONE|DES+CBC strconv: base64 # plain|base64|hex
func (Config) ToOption ¶
func (cfg Config) ToOption() MachineOption
type ConfigBlock ¶
type ConfigCipher ¶
type ConfigPadding ¶
type ConfigPadding struct {
Padding string `yaml:"padding"` // none|PKCS
}
type ConfigStrConv ¶
type ConfigStrConv struct {
StrConv string `yaml:"strconv"` // plain|base64|hex
}
type EncryptionMethod ¶
type EncryptionMethod int
ENUM( NONE AES DES )
const ( // EncryptionMethodNONE is a EncryptionMethod of type NONE. EncryptionMethodNONE EncryptionMethod = iota // EncryptionMethodAES is a EncryptionMethod of type AES. EncryptionMethodAES // EncryptionMethodDES is a EncryptionMethod of type DES. EncryptionMethodDES )
func ParseEncryptionMethod ¶
func ParseEncryptionMethod(name string) (EncryptionMethod, error)
ParseEncryptionMethod attempts to convert a string to a EncryptionMethod.
func (EncryptionMethod) BlockFactory ¶
func (method EncryptionMethod) BlockFactory() func(key []byte) (cipher.Block, error)
func (EncryptionMethod) String ¶
func (x EncryptionMethod) String() string
String implements the Stringer interface.
type Machine ¶
func NewMachine ¶
func NewMachine(opt MachineOption) (m *Machine, err error)
func (*Machine) DecodeDetail ¶
type MachineOption ¶
type MachineOption struct { Block struct { Method string `json:"block-method"` Size int `json:"block-size"` Key string `json:"block-key"` } `json:",inline"` Cipher struct { Mode string `json:"cipher-mode"` Salt *string `json:"cipher-salt,omitempty"` } `json:",inline"` Padding string `json:"padding"` StrConv string `json:"strconv"` }
type NoneEncripter ¶
type NoneEncripter struct{}
func (NoneEncripter) BlockSize ¶
func (encripter NoneEncripter) BlockSize() int
func (NoneEncripter) Decrypt ¶
func (encripter NoneEncripter) Decrypt(dst, src []byte)
func (NoneEncripter) Encrypt ¶
func (encripter NoneEncripter) Encrypt(dst, src []byte)
type Padding ¶
type Padding int
ENUM( NONE PKCS )
func ParsePadding ¶
ParsePadding attempts to convert a string to a Padding.
type StrConv ¶
type StrConv int
ENUM(
plain base64 hex )
func ParseStrConv ¶
ParseStrConv attempts to convert a string to a StrConv.