Created
December 26, 2014 11:59
-
-
Save atton/4f60caeac356d0b78254 to your computer and use it in GitHub Desktop.
password.hs
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
import System.Random | |
import System.Environment | |
import Data.Maybe | |
main = do | |
arg <- getArgs | |
gen <- newStdGen | |
putStrLn $ fromMaybe "" $ listToMaybe arg >>= (return . (password gen) . read) | |
-- putStrLn . (password gen) $ fromMaybe 0 $ listToMaybe arg >>= return . read | |
-- putStrLn . (password gen) . read $ fromMaybe "0" $ listToMaybe arg | |
where | |
characters = ['0'..'9']++['a'..'z']++['A'..'Z']++['!','$','%','@','#'] | |
password g x = take x $ zipWith (!!) (repeat characters) $ randomRs (0, (length characters) - 1) g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment