Documentation ¶
Index ¶
- Constants
- func IsDecrypted(text string) bool
- func IsEncrypted(text string) bool
- func ValidKey(key []byte) bool
- type Action
- type Crypto
- func (c *Crypto) Decrypt(cryptotext string) ([]byte, error)
- func (c *Crypto) DecryptValue(cryptotext string) ([]byte, error)
- func (c *Crypto) Encrypt(plaintext []byte) (string, error)
- func (c *Crypto) EncryptValue(plaintext []byte) (string, error)
- func (c *Crypto) Process(text string) (string, error)
- type KeyError
Constants ¶
const ( EnvKeyName = "KUBEKIT_KEY" KeyValidRules = "A key should have 16, 24 or 32 characters, should contain at least one number and at least one uppercase and lowercase letter" DefaultKeyPassphrase = "S3cr3t%PassW0rd!" )
EnvKeyName is the name of the environment variable to store the key KeyValidLen is the valid length for a key. A valid key should have an equal or larger length than KeyValidLen
Variables ¶
This section is empty.
Functions ¶
func IsDecrypted ¶
IsDecrypted returns true if the given text has the action to encrypt, returns true if it's decrypted/plaintext
func IsEncrypted ¶
IsEncrypted returns true if the given text has the action to decrypt, returns true if it's encrypted
Types ¶
type Action ¶
type Action int
Action defines an action like encrypt or decrypt
Defines all the possible CryptoActions
func ParseAction ¶
ParseAction returns the action to execute with the given text
type Crypto ¶
type Crypto struct {
Key []byte
}
Crypto is a struct to handle cryptography (encryption/decryption)
func (*Crypto) DecryptValue ¶
DecryptValue decrypts an encrypted text using the given key and returns it in the configuration format
func (*Crypto) EncryptValue ¶
EncryptValue encrypts a plain text using the given key and returns it in the configuration format