feat: Add support for masked password prompt#355
Merged
Conversation
djc
reviewed
Jul 8, 2026
djc
approved these changes
Jul 8, 2026
djc
left a comment
Member
There was a problem hiding this comment.
Looks okay modulo one nit. Please squash your commits.
TomPlanche
force-pushed
the
feat/masked-password
branch
from
July 8, 2026 10:37
84fee0a to
63e0082
Compare
TomPlanche
force-pushed
the
feat/masked-password
branch
from
July 8, 2026 10:39
63e0082 to
53ca34e
Compare
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional mask character to the
Passwordprompt. By default the input stays fully hidden (nothing echoed) exactly as before; when a mask is set, one mask character is echoed per typed character.Resolves #340.
Changes
with_mask(char)builder method onPassword, backed by amask: Option<char>field (Noneby default).Term::read_key()and a mask character is echoed for each printable character.Backspaceerases the last character;Entersubmits. This path mirrorsread_secure_line's trailing-newline behaviour so both code paths behave uniformly.read_secure_line).examples/password.rsto demonstrate the masked prompt.Notes
Option<char>field defaults toNone, preserving the current fully-hidden behaviour.read_masked_linereturns aStringand the caller wraps it inZeroizingininteract_on, identical to the existingread_secure_linepath, so the existing memory-scrubbing guarantee is unchanged.