Documentation ¶
Index ¶
- Constants
- func CipherModeNames() []string
- func EncryptionMethodNames() []string
- func LoadConfig(cfg Config) error
- func PKCS7Padding(src []byte, blockSize int) []byte
- func PKCS7Unpadding(src []byte) []byte
- func PaddingNames() []string
- func PrintConfig(w io.Writer, cfg Config)
- 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 ConfigCryptoAlgorithm
- 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 LoadConfig ¶
func PKCS7Padding ¶
func PKCS7Unpadding ¶
func PaddingNames ¶
func PaddingNames() []string
PaddingNames returns a list of possible string values of Padding.
func PrintConfig ¶
func StrConvNames ¶
func StrConvNames() []string
StrConvNames returns a list of possible string values of StrConv.
Types ¶
type BlockSize_AES ¶
type BlockSize_AES int
type Cipher ¶
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 {
CryptoAlgorithmSet map[string]ConfigCryptoAlgorithm `yaml:"enigma"`
}
Config
config-name: block-method: aes # NONE, AES, DES block-size: 128 # NONE: default(1), AES: 128|192|256, DES: 64 block-key: secret # (base64 string) cipher-mode: gcm # NONE: NONE|AES|DES , GCM: AES, CBC: NONE|AES|DES cipher-salt: null # NULL, (base64 string) padding: PKCS # NONE: AES+GCM, PKCS: AES+NONE|AES+CBC|DES+NONE|DES+CBC strconv: base64 # plain|base64|hex
type ConfigBlock ¶
type ConfigBlock struct { EncryptionMethod string `env:"ENIGMA_BLOCK_METHOD" yaml:"block-method"` // NONE|AES|DES BlockSize int `env:"ENIGMA_BLOCK_SIZE" yaml:"block-size"` // NONE: default(1), AES: [128|192|256], DES: [64] BlockKey string `env:"ENIGMA_BLOCK_KEY" yaml:"block-key"` // (base64 string) }
type ConfigCipher ¶
type ConfigCryptoAlgorithm ¶
type ConfigCryptoAlgorithm struct { ConfigBlock `yaml:",inline"` ConfigCipher `yaml:",inline"` ConfigPadding `yaml:",inline"` ConfigStrConv `yaml:",inline"` }
func (ConfigCryptoAlgorithm) ToOption ¶
func (cfg ConfigCryptoAlgorithm) ToOption() MachineOption
type ConfigPadding ¶
type ConfigPadding struct {
Padding string `env:"ENIGMA_PADDING" yaml:"padding"` // none|PKCS
}
type ConfigStrConv ¶
type ConfigStrConv struct {
StrConv string `env:"ENIGMA_STRCONV" 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 (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.