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

Copyright(c) Sean Gillespie, 2015
LicenseOtherLicense
MaintainerSean Gillespie <sean@mistersg.net>
StabilityExperimental
Safe HaskellNone
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

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

genPasswords Source

Arguments

:: RandomGen g 
=> Int

password length

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

newPassword Source

Arguments

:: RandomGen g 
=> Int

password length

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

newPasswords Source

Arguments

:: RandomGen g 
=> Int

password length

-> 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 = (take 10 . genPasswords 10) liftM getStdGen

mkPassword Source

Arguments

:: 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
 

mkPasswords Source

Arguments

:: 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

alphabet :: [Char] Source

The alphabet we sample random values from

Internal

first2 :: MonadRandom m => m String Source

Generate two random characters

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

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

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

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