File: Password.hs

package info (click to toggle)
haskell-echo 0.1.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 80 kB
  • sloc: haskell: 116; makefile: 5
file content (29 lines) | stat: -rw-r--r-- 781 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{-|
Module:      Password
Copyright:   (C) 2016-2017 Ryan Scott
License:     BSD-style (see the file LICENSE)
Maintainer:  Ryan Scott
Stability:   Provisional
Portability: Portable

A simple program which prompts you for your username and password (without
leaking your password onto the screen as you type it).
-}
module Main (main) where

import System.IO (hFlush, stdout)
import System.IO.Echo (withoutInputEcho)

main :: IO ()
main = do
    putLabel "Username: "
    username <- getLine
    putLabel "Password: "
    password <- withoutInputEcho getLine

    putStrLn ""
    putStrLn "-----------------------------------"
    putStrLn $ "Your username is: " ++ username
    putStrLn $ "Your password is: " ++ password
  where
    putLabel label = putStr label >> hFlush stdout