avtool

package module
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

README

avtool

Go Report Card Coverage Status go.dev reference

NOTE: Original code written by @pbthorste for https://github.com/pbthorste/avtool

HUGE SHOUT OUT to @pbthorste

This module provides a reimplementation of ansible-vault encrypt and decrypt functionality in Go.

CLI Tool

Please see gwvault for a purpose built ansible-vault binary written in go.

It leverages the work done by @pbthorste for https://github.com/pbthorste/avtool while further fleshing out the CLI tool to be more in line with the original ansible-vault CLI tool.

v2 to v3

In the v3.0.0 update there are breaking changes to the interface.

The Encrypt and Decrypt methods now expect the EncryptOptions and DecryptOptions parameter types as inputs.

The EncryptFile and DecryptFile methods now expect the EncryptFileOptions and DecryptFileOptions parameter types as inputs.

This change was made to allow for easier extension of the library without the need for future major version bumps.

Why the fork?

As of writing the mainline has been stale for ~4 years.

I have found this code to be highly useful and important for writing other ansible-vault related tools. I wanted to modernize the work done previously to support go.mod while also updating the interface as an importable module for other code.

Thanks and Attribution

Original code written by @pbthorste

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(opts *DecryptOptions) (result string, err error)

Decrypt a string containing the ansible vault

func DecryptFile

func DecryptFile(opts *DecryptFileOptions) (result string, err error)

DecryptFile reads content of filename, decrypts it and returns string

func Encrypt

func Encrypt(opts *EncryptOptions) (result string, err error)

Encrypt will vault encrypt a piece of data.

If EncryptOptions.VaultID is set, it will upversion to 1.2, otherwise it will default to using 1.1.

EncryptOptions.VaultID must not include `;`. If it does, an error will be thrown.

func EncryptFile

func EncryptFile(opts *EncryptFileOptions) (result string, err error)

EncryptFile reads content of filename provided and returns encrypted string

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes will generate n length bytes using rand.Read

Types

type DecryptFileOptions

type DecryptFileOptions struct {
	Filename string
	Password *[]byte
}

DecryptFileOptions is the interface used to pass data to the DecryptFile method

type DecryptOptions

type DecryptOptions struct {
	Data     *[]byte
	Password *[]byte
}

DecryptOptions is the interface used to pass data to the Decrypt method

type EncryptFileOptions

type EncryptFileOptions struct {
	Filename string
	Password *[]byte
	VaultID  string
}

EncryptFileOptions is the interface used to pass data to the EncryptFile method

type EncryptOptions

type EncryptOptions struct {
	Body     *[]byte
	Password *[]byte
	VaultID  string
}

EncryptOptions is the interface used to pass data to the Encrypt method

Jump to

Keyboard shortcuts

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