vault

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileMode = 0666
)

Variables

View Source
var (
	// ErrEmptyPassword is returned when password is empty
	ErrEmptyPassword = errors.New("password is blank")

	// ErrInvalidFormat is returned when secret content is not valid
	ErrInvalidFormat = errors.New("invalid secret format")

	// ErrInvalidPadding is returned when invalid key is used
	ErrInvalidPadding = errors.New("invalid padding")

	ErrKeyFileNotExec = errors.New("key file is not executable")

	ErrKeyFileNotFound = errors.New("key file not found")
)

Functions

func Decrypt

func Decrypt(input string, password string) (string, error)

Decrypt decrypts the input string with the vault password

func DecryptFile

func DecryptFile(path string, password string) (string, error)

DecryptFile decrypts the content of the file with the vault password

func Encrypt

func Encrypt(input string, password string, pad int) (string, error)

Encrypt encrypts the input string with the vault password

func EncryptFile

func EncryptFile(path string, input string, password string) error

EncryptFile encrypts the input string and saves it into the file

func GetKey

func GetKey(keyChoice Key, envPrefix string) (string, error)

get key from specified key or from env var if not specified

func GetKeyFromFile

func GetKeyFromFile(fileName string, run bool) (string, error)

obtain a key from a file, if run is true the file will be executed

func MaybeEncrypted

func MaybeEncrypted(input string) bool

Return true if the input maybe encrypted as an ansible vault

Types

type Key

type Key struct {
	Value  string
	IsFile bool
	IsExec bool
}

type KeyChoice

type KeyChoice struct {
	KeyExec string
	KeyFile string
	Key     string
}

Jump to

Keyboard shortcuts

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