The following Haskell program prompts the user for a password in the terminal and continues if he has entered the correct one:
main = do
putStrLn "Password:"
password <- getLine
case hash password `member` database of
False -> putStrLn "Unauthorized use!"
True -> do
...
Unfortunately, the password will appear on the screen as the user types it, which I want to avoid.
How can I read a sequence of characters that the users types without having the show up on the screen? What is the equivalent of
getLine
for this purpose?
I'm on MacOS X, but I would like this to work on Windows and Linux, too.
Maybe String
rather than aString
? There's no documentation on it, and it seems to me that it should always returnString
, like standardgetLine
. – Prothrombin