vault

package module
Version: v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 11 Imported by: 7

README

ansible-vault-go

Go package to read/write Ansible Vault secrets

GoDoc Go Report Card

Installation

go get github.com/sosedoff/ansible-vault-go

Usage

package main

import(
  "log"

  "github.com/sosedoff/ansible-vault-go"
)

func main() {
  // Encrypt secret data
  str, err := vault.Encrypt("secret", "password")

  // Decrypt secret data
  str, err := vault.Decrypt("secret", "password")

  // Write secret data to file
  err := vault.EncryptFile("path/to/secret/file", "secret", "password")

  // Read existing secret
  str, err := vault.DecryptFile("path/to/secret/file", "password")
}

Doc

Check out the Ansible documentation regarding the Vault file format:

License

MIT

Documentation

Index

Constants

This section is empty.

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")
)

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) (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

Types

This section is empty.

Jump to

Keyboard shortcuts

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