Prompting for a password in Haskell command line application

前端 未结 6 959
傲寒
傲寒 2021-02-01 04:10

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:         


        
6条回答
  •  面向向阳花
    2021-02-01 04:14

    There is a getPassword in System.Console.Haskeline. Probably it's an overkill for your case but someone may find it useful.

    An example:

    > runInputT defaultSettings $ do {p <- getPassword (Just '*') "pass:"; outputStrLn $ fromJust p}
    pass:***
    asd
    

提交回复
热议问题