Documentation
¶
Overview ¶
Package secret provide functions to encrypting and decrypting text such that the text can be persisted in a configuration file (xml / yaml / json etc.)
Index ¶
- func Decode(cipherText string, passwordEncryption string) (plainText string)
- func DecodeAsUtf16(cipherText string, passwordEncryption string) []byte
- func Encode(plainText string, passwordEncryption string) (cipherText string)
- func EncryptionMethodsForUsage() string
- func Generate(passwordLength, minSpecialChar, minNum, minUpperCase int, ...) string
- func Initialize(handler func(err error))
- func IsValidEncryptionMethod(method string) bool
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode takes a cipher text and a boolean indicating whether to decrypt the cipher text using a password, and returns the resulting plain text. If the cipher text is an empty string, this function will panic.
func DecodeAsUtf16 ¶ added in v0.13.0
DecodeAsUtf16 takes a cipher text and a boolean indicating whether to decrypt and returns the resulting plain text as a byte array in UTF-16 format which is required when passing the secret to applications written using managed code (C#), such as Azure Data Studio.
func Encode ¶
Encode takes a plain text string and a boolean indicating whether or not to encrypt the plain text using a password, and returns the resulting cipher text. If the plain text is an empty string, this function will panic.
func EncryptionMethodsForUsage ¶ added in v0.15.3
func EncryptionMethodsForUsage() string
EncryptionMethodsForUsage return the encryption methods for the current OS as comma separated string for use in help text
func Generate ¶
func Generate(passwordLength, minSpecialChar, minNum, minUpperCase int, specialCharSet string) string
Generate generates a random password of a specified length. The password will contain at least the specified number of special characters, numeric digits, and upper-case letters. The remaining characters in the password will be selected from a combination of lower-case letters, special characters, and numeric digits. The special characters are chosen from the provided special character set. The generated password is returned as a string.
func Initialize ¶
func Initialize(handler func(err error))
func IsValidEncryptionMethod ¶ added in v0.15.3
IsValidEncryptionMethod returns true if the method is a valid encryption method
Types ¶
This section is empty.
Notes ¶
Bugs ¶
Encryption not yet implemented on linux
Encryption not yet implemented on linux
Temporary code, remove when rolling over to v1.0.0, needed as very early users migrated from the old password-encrypted bool value