crypt

package
v0.32.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//Parser is a new Parser with default options
	Parser = flags.NewParser(&defaultOptions, flags.Default)
)

Functions

func CipherBytes

func CipherBytes(plaintext []byte, singleLine, disableValidation bool) (cipherBytes []byte)

CipherBytes uses 'defaultOptions' go-flags to encrypt plaintext bytes and return ciphertext bytes

func CipherBytesFromPrimitives

func CipherBytesFromPrimitives(plaintext []byte, singleLine,
	disableValidation bool,
	projectID, locationID, keyRingID, cryptoKeyID, keyName string,
	kmsProvider KmsProvider) (cipherBytes []byte)

CipherBytesFromPrimitives encrypts plaintext bytes and returns ciphertext bytes

func CipherText

func CipherText(plaintext []byte, filepath string, singleLine, disableValidation bool) (err error)

CipherText creates a ciphertext encrypted from a slice of bytes (the plaintext), and writes to File and Console.

func PlainText

func PlainText(filepath string) (plaintext []byte, err error)

PlainText returns a slice of bytes (the plaintext), decrypted from File

func PlainTextFromBytes

func PlainTextFromBytes(cipherBytes []byte) (plaintext []byte, err error)

PlainTextFromBytes returns a slice of bytes (the plaintext), decrypted from a byte slice

func PlainTextFromPrimitives

func PlainTextFromPrimitives(cipherBytes []byte,
	projectID, locationID, keyRingID, cryptoKeyID, keyName string,
	kmsProvider KmsProvider) (plaintext []byte, err error)

PlainTextFromPrimitives returns a slice of bytes (the plaintext), decrypted from a byte slice

func Reencrypt

func Reencrypt(filepath string, singleLine, disableValidation bool) error

Reencrypt decrypts into a plaintext byte array, and encrypts back to ciphertext file

Types

type AwsKms

type AwsKms struct{}

AwsKms type

type DecryptCommand

type DecryptCommand struct {
	Filepath         string `short:"f" long:"filepath" description:"Path of file to get encrypted string from" default:"./cipher.txt"`
	RetainCipherText bool   `short:"r" long:"retainCipherText" description:"Retain ciphertext after decryption"`
	TargetFilepath   string `short:"t" long:"targetFilepath" description:"Path of file to write decrypted string to" default:"./plain.txt"`
	Validate         bool   `short:"v" long:"validate" description:"Validate decryption works"`
	WriteToStdout    bool   `short:"o" long:"stdout" description:"Writes decrypted plaintext to console"`
}

DecryptCommand type

func (*DecryptCommand) Execute

func (x *DecryptCommand) Execute(args []string) error

Execute executes the DecryptCommand

type Defaults

type Defaults struct {
	CryptoKeyID string `short:"c" long:"cryptokeyId" description:"Google KMS crytoKeyId" required:"false"`
	KeyRingID   string `short:"k" long:"keyringId" description:"Google KMS keyRingId" required:"false"`
	KeyName     string `short:"n" long:"keyName" description:"Google KMS keyName or AWS KMS keyId" required:"false"`
	LocationID  string `short:"l" long:"locationId" description:"Google KMS locationId" required:"false"`
	ProjectID   string `short:"p" long:"projectId" description:"Google projectId" required:"false"`
	KMSProvider string `short:"m" long:"kmsProvider" description:"KMS provider" required:"false"`
}

Defaults type defining input flags

type EncryptCommand

type EncryptCommand struct {
	DisableValidation bool   `short:"d" long:"disableValidation" description:"Disable validation of ciphertext"`
	Filepath          string `short:"f" long:"filepath" description:"Path of file to encrypt" default:"./plain.txt"`
	SingleLine        bool   `short:"s" long:"singleLine" description:"Disable use of newline chars in ciphertext"`
}

EncryptCommand type

func (*EncryptCommand) Execute

func (x *EncryptCommand) Execute(args []string) (err error)

Execute executes the EncryptCommand

type GcpKms

type GcpKms struct{}

GcpKms type

type KmsProvider

type KmsProvider interface {
	// contains filtered or unexported methods
}

KmsProvider type

type ReencryptCommand

type ReencryptCommand struct {
	DisableValidation bool   `short:"d" long:"disableValidation" description:"Disable validation of ciphertext"`
	Filepath          string `short:"f" long:"filepath" description:"Path of file to get encrypted string from" default:"./cipher.txt"`
	SingleLine        bool   `short:"s" long:"singleLine" description:"Disable use of newline chars in ciphertext"`
}

ReencryptCommand type

func (*ReencryptCommand) Execute

func (x *ReencryptCommand) Execute(args []string) error

Execute executes the ReencryptCommand

Jump to

Keyboard shortcuts

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