public bool read_from_tty(string password) { const char BACKSPACE = 127; password.reserve(max_password_size); while (password.Length < max_password_size) { int ch = GlobalMembers.getch(); if (EOF == ch) { return(false); } else if (ch == '\n' || ch == '\r') { Console.Write("\n"); break; } else if (ch == BACKSPACE) { if (!string.IsNullOrEmpty(password)) { password.back() = '\0'; password.resize(password.Length - 1); Console.Write("\b \b"); } } else { password.push_back(ch); Console.Write('*'); } } return(true); }