Created
May 9, 2011 06:03
-
-
Save bradclawsie/962123 to your computer and use it in GitHub Desktop.
haskell pw prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System.IO | |
import Data.Char | |
import System.Console.ANSI | |
-- ord val of 10 is return key | |
getPW = getPW' "" where | |
getPW' s = getChar >>= \x -> | |
if ((ord x) == 10) then return s | |
else cursorBackward 1 >> putStr "*" >> getPW' (s ++ [x]) | |
main = | |
hSetBuffering stdin NoBuffering >> | |
hSetBuffering stdout NoBuffering >> | |
putStrLn "pass:" >> | |
getPW >>= \pw -> putStr pw >> clearScreen >> return () | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment