-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.hs
42 lines (32 loc) · 1.24 KB
/
Main.hs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
{-|
Copyright:
This file is part of the package zxcvbn-hs. It is subject to the
license terms in the LICENSE file found in the top-level directory
of this distribution and at:
https://code.devalot.com/sthenauth/zxcvbn-hs
No part of this package, including this file, may be copied,
modified, propagated, or distributed except according to the terms
contained in the LICENSE file.
License: MIT
-}
module Main (main) where
--------------------------------------------------------------------------------
-- Imports:
import qualified Data.Text.IO as Text
import Data.Time.Clock (getCurrentTime, utctDay)
import System.IO
import Text.Password.Strength
--------------------------------------------------------------------------------
-- | Read a password from stdin and score it.
main :: IO ()
main = do
-- Turn off buffering for the password prompt below:
hSetBuffering stdout NoBuffering
-- Get the date and read a password:
refDay <- utctDay <$> getCurrentTime
password <- putStr "Password: " >> Text.getLine
-- Get the score for the password we just read:
let s = score en_US refDay password
-- Output some info about the score:
putStrLn (" Score: " ++ show (getScore s))
putStrLn ("Strength: " ++ show (strength s))