Copyright | (c) Sean Gillespie, 2015 |
---|---|
License | OtherLicense |
Maintainer | Sean Gillespie <sean@mistersg.net> |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
Generate easy-to-remember, hard-to-guess passwords
- genPassword :: RandomGen g => Int -> g -> (String, g)
- genPasswords :: RandomGen g => Int -> g -> ([String], g)
- newPassword :: RandomGen g => Int -> g -> String
- newPasswords :: RandomGen g => Int -> g -> [String]
- mkPassword :: MonadRandom m => Int -> m String
- mkPasswords :: MonadRandom m => Int -> m [String]
- alphabet :: [Char]
- first2 :: MonadRandom m => m String
- next :: MonadRandom m => String -> m Char
- lastN :: MonadRandom m => String -> Int -> m String
Random password generators
Generate a password using the generator g, returning the result and the updated generator.
-- Generate a password of length 10 using the system generator myGenPassword :: IO (String, StdGen) myGenPassword = genPassword 10 `liftM` getStdGen
Plural version of genPassword. Generates an infinite list of passwords using the generator g, returning the result and the updated generator.
-- Generate 10 passwords of length 10 using the system generator myGenPasswords :: IO ([String], StdGen) myGenPasswords = ((ls, g) -> (take 10 ls, g)liftM
genPasswords 10liftM
getStdGen
Generate a password using the generator g, returning the result.
-- Generate a password of length 10 using the system generator myNewPassword :: IO String myNewPassword = newPassword 10 `liftM` getStdGen
Plural version of newPassword. Generates an infinite list of passwords using the generator g, returning the result
-- Generate 10 passwords of length 10 using the system generator
myNewPasswords :: IO [String]
myNewPasswords = (take 10 . genPasswords 10) liftM
getStdGen
:: MonadRandom m | |
=> Int | password length |
-> m String |
Generate a password using the MonadRandom m. MonadRandom is exposed here for extra control.
-- Generate a password of length 10 using the system generator myPasswords :: IO String myPasswords = evalRand (mkPassword 10) `liftM` getStdGen
:: MonadRandom m | |
=> Int | password length |
-> m [String] |
Plural version of mkPassword. Generate an infinite list of passwords using the MonadRandom m. MonadRandom is exposed here for extra control.
-- Generate an infinite list of passwords of length 10 using the system generator myMkPasswords :: IO [String] myMkPasswords = evalRand (mkPasswords 10) `liftM` getStdGen
Internal
first2 :: MonadRandom m => m String Source
Generate two random characters