elocrypt-1.0.0: Generate easy-to-remember, hard-to-guess passwords

Copyright(c) Sean Gillespie 2015
LicenseOtherLicense
MaintainerSean Gillespie <sean@mistersg.net>
StabilityExperimental
Safe HaskellSafe
LanguageHaskell2010

Data.Elocrypt

Contents

Description

Generate easy-to-remember, hard-to-guess passwords

Synopsis

Random password generators

genPassword Source #

Arguments

:: RandomGen g 
=> Int

password length

-> Bool

include capitals?

-> g

random generator

-> (String, g) 

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 True `liftM` getStdGen
 

genPasswords Source #

Arguments

:: RandomGen g 
=> Int

password length

-> Int

number of passwords

-> Bool

include capitals?

-> g

random generator

-> ([String], g) 

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) -> (ls, g) liftM genPasswords 10 10 True liftM getStdGen

newPassword Source #

Arguments

:: RandomGen g 
=> Int

password length

-> Bool

include capitals?

-> g

random generator

-> String 

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 True `liftM` getStdGen
 

newPasswords Source #

Arguments

:: RandomGen g 
=> Int

password length

-> Int

number of passwords

-> Bool

include capitals?

-> g

random generator

-> [String] 

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 = genPasswords 10 10 True liftM getStdGen

mkPassword Source #

Arguments

:: MonadRandom m 
=> Int

password length

-> Bool

include capitals?

-> 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
 myPassword :: IO String
 myPassword = evalRand (mkPassword 10 True) `liftM` getStdGen
 

mkPasswords Source #

Arguments

:: MonadRandom m 
=> Int

password length

-> Int

number of passwords

-> Bool

include capitals?

-> 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 list of length 20 with passwords of length 10 using the system generator
myMkPasswords :: IO [String]
myMkPasswords = evalRand (mkPasswords 10 20 True) `liftM` getStdGen

Random passphrase generators

genPassphrase Source #

Arguments

:: RandomGen g 
=> Int

number of words

-> Int

minimum word length

-> Int

maximum word length

-> g

random generator

-> ([String], g) 

Generate a passphrase using the generator g, returning the result and the updated generator.

 -- Generate a passphrase of 10 words, each having a length between 6 and 12,
 -- using the system generator
 myGenPassphrase :: IO (String, StdGen)
 myGenPassphrase = genPassword 10 True `liftM` getStdGen
 

newPassphrase Source #

Arguments

:: RandomGen g 
=> Int

number of words

-> Int

minimum word length

-> Int

maximum word length

-> g

random generator

-> [String] 

Generate a passphrase using the generator g, returning the result.

 -- Generate a passphrase of 10 words, each having a length between 6 an 12,
 -- using the system generator.
 myNewPassphrase :: IO String
 myNewPassphrase = newPassphrase 10 6 12 `liftM` getStdGen
 

mkPassphrase Source #

Arguments

:: MonadRandom m 
=> Int

number of words

-> Int

minimum word length

-> Int

maximum word length

-> m [String] 

Generate a finite number of words of random length (between min and max chars) using the MonadRandom m. MonadRandom is exposed here for extra control.

 -- Generate a passphrase of 10 words, each having a length between 6 and 12.
 myPassphrase :: IO String
 myPassphrase = evalRand (mkPassphrase 10 6 12) `liftM` getStdGen
 

Internal

alphabet :: [Char] Source #

The alphabet we sample random values from

first2 :: MonadRandom m => m String Source #

Generate two random characters. Uses trigragh to generate a weighted list.

next :: MonadRandom m => String -> m Char Source #

Generate a random character based on the previous two characters and their trigraph

lastN :: MonadRandom m => Int -> String -> m String Source #

Generate the last n characters using previous two characters and their trigraph