gibberish-3.0.0.0: Generate easy-to-remember, hard-to-guess passwords
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Gibberish

Synopsis

Generating Passwords

genPassword :: MonadRandom m => GenPasswordOpts -> m Word Source #

Generate a password with the given options

genPasswords :: MonadRandom m => GenPasswordOpts -> m [Word] Source #

Generate passwords with the given options. Warning: Do not use with the IO monad, instead use genPasswords'

Generating Passphrases

genPassphrase :: MonadRandom m => GenPassphraseOpts -> m [Word] Source #

Generate a passphrase with the given options. Warning: Do not use with the IO monad, instead use genPassphrash'

genPassphrase' :: MonadRandom m => GenPassphraseOpts -> Int -> m [Word] Source #

Generate a passphrase with the given options and the given number of words.

The Pass Monad

type Pass gen = PassT gen Identity Source #

Password/Passphrase generation monad parameterized by the type gen of the generator to carry

runPass :: Pass gen a -> gen -> (a, gen) Source #

Run a generation computation with the given options and initial generator

evalPass :: Pass gen a -> gen -> a Source #

Evaluate a generation computation with the given options and initial generator, discarding the final generator

usingPass :: gen -> Pass gen a -> (a, gen) Source #

Shorter and more readable alias for flip runPassT.

The PassT Monad Transformer

newtype PassT gen m a Source #

Password/Passphrase generation transformer monad parameterized by :

  • gen - the generator.
  • m - the inner monad.

Constructors

PassT 

Fields

Instances

Instances details
(RandomGen gen, Monad m) => MonadRandom (PassT gen m) Source # 
Instance details

Defined in Data.Gibberish.Monad.Pass

Methods

getRandomR :: Random a => (a, a) -> PassT gen m a #

getRandom :: Random a => PassT gen m a #

getRandomRs :: Random a => (a, a) -> PassT gen m [a] #

getRandoms :: Random a => PassT gen m [a] #

MonadFail m => MonadFail (PassT gen m) Source # 
Instance details

Defined in Data.Gibberish.Monad.Pass

Methods

fail :: String -> PassT gen m a #

MonadIO m => MonadIO (PassT gen m) Source # 
Instance details

Defined in Data.Gibberish.Monad.Pass

Methods

liftIO :: IO a -> PassT gen m a #

Monad m => Applicative (PassT gen m) Source # 
Instance details

Defined in Data.Gibberish.Monad.Pass

Methods

pure :: a -> PassT gen m a #

(<*>) :: PassT gen m (a -> b) -> PassT gen m a -> PassT gen m b #

liftA2 :: (a -> b -> c) -> PassT gen m a -> PassT gen m b -> PassT gen m c #

(*>) :: PassT gen m a -> PassT gen m b -> PassT gen m b #

(<*) :: PassT gen m a -> PassT gen m b -> PassT gen m a #

Functor m => Functor (PassT gen m) Source # 
Instance details

Defined in Data.Gibberish.Monad.Pass

Methods

fmap :: (a -> b) -> PassT gen m a -> PassT gen m b #

(<$) :: a -> PassT gen m b -> PassT gen m a #

Monad m => Monad (PassT gen m) Source # 
Instance details

Defined in Data.Gibberish.Monad.Pass

Methods

(>>=) :: PassT gen m a -> (a -> PassT gen m b) -> PassT gen m b #

(>>) :: PassT gen m a -> PassT gen m b -> PassT gen m b #

return :: a -> PassT gen m a #

runPassT :: PassT g m a -> g -> m (a, g) Source #

Run a generation computation with the given options and initial generator

evalPassT :: Monad m => PassT g m a -> g -> m a Source #

Evaluate a generation computation with the given options and initial generator, discarding the final generator

usingPassT :: g -> PassT g m a -> m (a, g) Source #

Shorter and more readable alias for flip runPassT.

Core Types

data GenPasswordOpts Source #

Password generation options

Constructors

GenPasswordOpts 

Fields

data GenPassphraseOpts Source #

Passphrase generation options

Constructors

GenPassphraseOpts 

Fields

data Language Source #

A language indicating the dictionary that generated a trigraph

Instances

Instances details
Show Language Source # 
Instance details

Defined in Data.Gibberish.Types

Eq Language Source # 
Instance details

Defined in Data.Gibberish.Types

newtype TrigraphConfig Source #

A path to a trigraph json config file

Constructors

TrigraphConfig 

Instances

Instances details
Show TrigraphConfig Source # 
Instance details

Defined in Data.Gibberish.Types

Eq TrigraphConfig Source # 
Instance details

Defined in Data.Gibberish.Types

newtype Trigraph Source #

A trigraph is a mapping of all digrams to frequencies. That is, for a set of digrams, it contains the frequencies of all possible trigram candidates.

Constructors

Trigraph 

Instances

Instances details
FromJSON Trigraph Source # 
Instance details

Defined in Data.Gibberish.Types

ToJSON Trigraph Source # 
Instance details

Defined in Data.Gibberish.Types

Show Trigraph Source # 
Instance details

Defined in Data.Gibberish.Types

NFData Trigraph Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

rnf :: Trigraph -> () #

Eq Trigraph Source # 
Instance details

Defined in Data.Gibberish.Types

newtype Word Source #

A natural language word

Constructors

Word 

Fields

Instances

Instances details
Show Word Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

showsPrec :: Int -> Word -> ShowS #

show :: Word -> String #

showList :: [Word] -> ShowS #

Eq Word Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

(==) :: Word -> Word -> Bool #

(/=) :: Word -> Word -> Bool #

newtype Unigram Source #

A unigram is a single letter

Constructors

Unigram 

Fields

Instances

Instances details
FromJSON Unigram Source # 
Instance details

Defined in Data.Gibberish.Types

FromJSONKey Unigram Source # 
Instance details

Defined in Data.Gibberish.Types

ToJSON Unigram Source # 
Instance details

Defined in Data.Gibberish.Types

ToJSONKey Unigram Source # 
Instance details

Defined in Data.Gibberish.Types

Show Unigram Source # 
Instance details

Defined in Data.Gibberish.Types

NFData Unigram Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

rnf :: Unigram -> () #

Eq Unigram Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

(==) :: Unigram -> Unigram -> Bool #

(/=) :: Unigram -> Unigram -> Bool #

Ord Unigram Source # 
Instance details

Defined in Data.Gibberish.Types

data Digram Source #

A digram is a sequence of two letters

Constructors

Digram Char Char 

Instances

Instances details
FromJSON Digram Source # 
Instance details

Defined in Data.Gibberish.Types

FromJSONKey Digram Source # 
Instance details

Defined in Data.Gibberish.Types

ToJSON Digram Source # 
Instance details

Defined in Data.Gibberish.Types

ToJSONKey Digram Source # 
Instance details

Defined in Data.Gibberish.Types

Generic Digram Source # 
Instance details

Defined in Data.Gibberish.Types

Associated Types

type Rep Digram :: Type -> Type #

Methods

from :: Digram -> Rep Digram x #

to :: Rep Digram x -> Digram #

Show Digram Source # 
Instance details

Defined in Data.Gibberish.Types

NFData Digram Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

rnf :: Digram -> () #

Eq Digram Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

(==) :: Digram -> Digram -> Bool #

(/=) :: Digram -> Digram -> Bool #

Ord Digram Source # 
Instance details

Defined in Data.Gibberish.Types

TextShow Digram Source # 
Instance details

Defined in Data.Gibberish.Types

type Rep Digram Source # 
Instance details

Defined in Data.Gibberish.Types

type Rep Digram = D1 ('MetaData "Digram" "Data.Gibberish.Types" "gibberish-3.0.0.0-CtpaXLVJUM23TyUN22m77c" 'False) (C1 ('MetaCons "Digram" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Char) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Char)))

data Trigram Source #

A trigrams is a sequence of three letters

Constructors

Trigram Char Char Char 

Instances

Instances details
Generic Trigram Source # 
Instance details

Defined in Data.Gibberish.Types

Associated Types

type Rep Trigram :: Type -> Type #

Methods

from :: Trigram -> Rep Trigram x #

to :: Rep Trigram x -> Trigram #

Show Trigram Source # 
Instance details

Defined in Data.Gibberish.Types

NFData Trigram Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

rnf :: Trigram -> () #

Eq Trigram Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

(==) :: Trigram -> Trigram -> Bool #

(/=) :: Trigram -> Trigram -> Bool #

Ord Trigram Source # 
Instance details

Defined in Data.Gibberish.Types

type Rep Trigram Source # 
Instance details

Defined in Data.Gibberish.Types

newtype Frequency Source #

A frequency represents the number of times a given trigram occurs in a language

Constructors

Frequency 

Fields

Instances

Instances details
FromJSON Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

ToJSON Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

Enum Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

Num Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

Integral Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

Real Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

Show Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

NFData Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

Methods

rnf :: Frequency -> () #

Eq Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

Ord Frequency Source # 
Instance details

Defined in Data.Gibberish.Types

newtype Frequencies Source #

Frequencies maps a unigram to a frequency

Error Handling

Working with Trigraphs

genTrigraph :: [Text] -> Trigraph Source #

Generate trigraphs from a list of words