passphrase

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package passphrase provides passphrase input handling for encryption.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPassphraseMismatch is returned when confirmation doesn't match.
	ErrPassphraseMismatch = errors.New("passphrases do not match")
	// ErrCancelled is returned when user cancels the operation.
	ErrCancelled = errors.New("operation cancelled")
)

Functions

This section is empty.

Types

type Prompter

type Prompter struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	// contains filtered or unexported fields
}

Prompter handles passphrase input prompts.

func (*Prompter) PromptForDecrypt

func (p *Prompter) PromptForDecrypt() (string, error)

PromptForDecrypt prompts for passphrase for decryption (no confirmation).

func (*Prompter) PromptForEncrypt

func (p *Prompter) PromptForEncrypt() (string, error)

PromptForEncrypt prompts for passphrase with confirmation for encryption. Returns empty string if user chooses to continue without encryption after warning. Returns ErrCancelled if user declines to continue without encryption.

func (*Prompter) ReadFromStdin

func (p *Prompter) ReadFromStdin() (string, error)

ReadFromStdin reads a single line from stdin without prompting. Used with --passphrase-stdin flag for non-interactive input.

func (*Prompter) UseBufReader added in v1.8.0

func (p *Prompter) UseBufReader(r *bufio.Reader)

UseBufReader shares an externally-owned buffered stdin reader with this Prompter. Reading a single piped stdin across more than one Prompter (e.g. a passphrase prompt followed by a confirmation prompt) requires them to share one buffered reader; otherwise a second bufio.Reader over the same fd finds the bytes already read-ahead into the first buffer and hits EOF.

func (*Prompter) WarnNonTTY

func (p *Prompter) WarnNonTTY()

WarnNonTTY prints warning for non-TTY environment.

Jump to

Keyboard shortcuts

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