AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 351 forks source link

Password input without revealing password length #386

Closed quiquelhappy closed 1 year ago

quiquelhappy commented 2 years ago

Hello, I'd link to render "", instead of "*" for the password input: similar to what linux does with pretty much every password input (aka invisible password input)

mislav commented 2 years ago

Hello, thank you for the valid feature request! Right now, it doesn't seem that the Password input prompt allows modifying how the entered password is displayed. If, for example, the * replacement character was configurable, it could be configured using an empty string instead. Contributions to add this functionality are welcome.

In the meantime, I suggest that you make your own password prompt. You can use this package instead of Survey: https://pkg.go.dev/golang.org/x/term#ReadPassword

AlecAivazis commented 1 year ago

This can now be accomplished by setting the HideCharacter to a zero-width space

szh commented 1 year ago

I tried this today and the cursor moves ahead which still reveals the password length.

mislav commented 1 year ago

@szh Thanks for reporting. Sounds like the visual representation is likely going to vary between terminal emulators. You are welcome to open a new issue about that 👍

szh commented 1 year ago

OK. I'll submit a PR for this.