Documentation
¶
Overview ¶
Package passphrase provides passphrase input handling for encryption.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
PromptForDecrypt prompts for passphrase for decryption (no confirmation).
func (*Prompter) PromptForEncrypt ¶
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 ¶
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
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.