2.9 KiB
2.9 KiB
password generation in armour
armour provides with tools to generate secure
passwords based on criteria in armour.gen.gen
to generate passwords based off criteria construct PwGenerator
with
ur criteria, keep in mind that values of -1
( armour.gen.gen.D
constant ) suggest 'any', which are the
defaults for min_
and max_
arguments
PwGenerator
takes in these arguments ( all optional ) :
rand
-- randomness source ( defaults toarmour.crypt.RAND
)byteset
-- the set of bytes to use in the password- if set to
None
uses random bytes - by default uses all printable characters
- if set to
length
-- the wanted password lengthmin_lower
-- minimum count of lowercase lettersmin_upper
-- minimum count of uppercase lettersmin_numbers
-- minimum count of numeric charactersmin_special
-- minimum count of special charactersmin_alphabet
-- minimum length of the password alphabetmax_sequences
-- maximum count of sequencesmax_common_patterns
-- maximum count common patternsmin_entropy
-- minimum entropy bitsmin_strength
-- minimum strengthmax_weakness
-- maximum weaknessmin_actual_strength
-- minimum realistic strengthmax_passes
-- the times to try to find the password ( defaults to1024
)- if set to
None
will try forever til it finds something
- if set to
methods u can call on PwGenerator
instance :
checks
-- get all the checks for the passwords- tuple of (value, check) tuples where check is a callable that returns if the condition passed or not
- takes in a
PasswordInfo
object to use
gen_one
-- try to generate a new password- returns
None
if it couldnt generate a good one based on ur criteria - returns
PasswordInfo
on success
- returns
gen
-- try to generate the passwordmax_passes
times or forever- returns
None
if it couldnt find a good password - returns
PasswordInfo
on success
- returns
example
>>> import armour
>>> print(armour.gen.gen.PwGenerator().gen())
length 128
lowercase 'yepwjwofsavvpqdpbkrvmkrgszpptkudpmpsljnpgtll'
uppercase 'SMIICIHDTIFDKBVJYJMTCRPVYHRJFXQXYYL'
numbers '79717233175'
special '`;`<^!_}#.;<^{!(-{#:|?/@.$+/<"`"\\\'*<~+.'
alphabet '!"#$\\\'(*+-./123579:;<?@BCDFHIJKLMPQRSTVXY^_`abdefgjklmnopqrstuvwyz{|}~'
alphabet combos 23587592395905693351442904560302022254467234770425414285469530657504535801364915816432245490596299658923687643435038957720860320754227185558333794857703311787045162048625406818415063860534352804900792572705170993013538266734645947850241
sequences 4
- 'YY' ( from 118 to 120 )
- 'll' ( from 124 to 126 )
common patterns 0
<none>
entropy bits 5.896217089725436
strength 1296.6814200733052
weakness 0
actual strength 5591.938624066129