Open magicl opened 8 years ago
I've done this with terminal.d: https://github.com/adamdruppe/arsd/blob/master/terminal.d
/**
* Requests a user's password without displaying the text entered.
*/
string getPassword() {
import terminal;
auto term = Terminal(ConsoleOutputType.linear);
auto input = RealTimeConsoleInput(&term, ConsoleInputFlags.raw);
string pass;
dchar ch;
ch = input.getch();
while(ch != '\r' && ch != '\n')
{
import std.range;
if(ch == '\b' && !pass.empty)
pass = pass[0..$-1];
else
pass ~= ch;
ch = input.getch();
}
return pass;
}
Would be great to have a version of userInput that masked what was typed, e.g. using "read -s"