rustyline icon indicating copy to clipboard operation
rustyline copied to clipboard

Read password

Open gwenn opened this issue 9 years ago • 9 comments

Disable echo...

gwenn avatar Jul 27 '16 20:07 gwenn

https://github.com/antirez/linenoise/issues/125

Reading passwords securely requires more than that. Usually you want to ensure no one else is reading the input and that you are really connected to a terminal etc.

gwenn avatar Jan 12 '19 12:01 gwenn

I'm looking for this. It doesn't even have to be incredibly secure, just hiding the visible input would be enough for lots of cases.

madprops avatar Aug 12 '19 22:08 madprops

@madprops You can try something like this:

  • Disable auto_add_history so that password does not appear in your history file.
  • Define a Highlighter such as highlight returns '*' x width(line) because rustyline expects the highlighted line to have the same width as the raw line and highlight_char returns true.
  • And force highlighting: color_mode.

gwenn avatar Aug 14 '19 18:08 gwenn

Hmm not sure how to do this. It seems to define a highlighter I need to provide a helper, and to do that I need to implement all the helper stuff, not just the highlight? Can't find an easier way. Also in my case I think I don't need to bother about the history bit, since I'm not using history features in my inputs.

madprops avatar Aug 15 '19 00:08 madprops

@madprops I know, this is just a hack. I will try to provide you a complete example.

gwenn avatar Aug 15 '19 02:08 gwenn

See #266

gwenn avatar Aug 15 '19 03:08 gwenn

https://github.com/antirez/linenoise/pull/182

gwenn avatar Apr 13 '20 11:04 gwenn

Using a * per input character rather than nothing is less secure as it leaks the length of the password.

bjorn3 avatar Apr 13 '20 12:04 bjorn3