secret

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(cipherText string, passwordEncryption string) (plainText string)

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

func DecodeAsUtf16(cipherText string, passwordEncryption string) []byte

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

func Encode(plainText string, passwordEncryption string) (cipherText string)

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

func IsValidEncryptionMethod(method string) bool

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL