modulepackage
0.2.0
Repository: https://github.com/sosedoff/ansible-vault-go.git
Documentation: pkg.go.dev
# README
ansible-vault-go
Go package to read/write Ansible Vault secrets
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
# Functions
Decrypt decrypts the input string with the vault password.
DecryptFile decrypts the content of the file with the vault password.
Encrypt encrypts the input string with the vault password.
EncryptFile encrypts the input string and saves it into the file.
# Variables
ErrEmptyPassword is returned when password is empty.
ErrInvalidFormat is returned when secret content is not valid.
ErrInvalidPadding is returned when invalid key is used.