c,python: Add the 'b' pattern for base64 encoded strings
Change the default pattern to use a short base64 string at the end. This increses the used bits to generate a password from 65 to 73.
This commit is contained in:
@ -10,11 +10,14 @@ from . import bhash, phogen
|
||||
#
|
||||
# WARNING: Changing any of the parameters below will affect password generation
|
||||
#
|
||||
PASSGENY_DEFAULT_PATTERN = "^6p^6p^6ps2p100d"
|
||||
PASSGENY_DEFAULT_PATTERN = "^6p^6p^6ps3b10d"
|
||||
|
||||
# List of special characters
|
||||
PASSGENY_SPECIAL = " +-./=_"
|
||||
|
||||
# List of base64 characters
|
||||
PASSGENY_BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
|
||||
# Default SALT to use; this cannot be random since passgeny must
|
||||
# generate predictable passwords
|
||||
PASSGENY_SALT_DEFAULT = b"Passgeny v1"
|
||||
@ -93,6 +96,12 @@ class Passgeny:
|
||||
x += "{:x}".format(bh.modulo(16))
|
||||
return x
|
||||
|
||||
def gen_base64(match):
|
||||
blen = 1 if match[1] == "" else int(match[1])
|
||||
b = ""
|
||||
for l in range(blen):
|
||||
b += PASSGENY_BASE64[bh.modulo(len(PASSGENY_BASE64))]
|
||||
return b
|
||||
|
||||
def gen_capitalize(match):
|
||||
nonlocal flags
|
||||
@ -104,6 +113,7 @@ class Passgeny:
|
||||
[ '([0-9]*)s', gen_special ],
|
||||
[ '([0-9]+)d', gen_decimal ],
|
||||
[ '([0-9]+)x', gen_hexstr ],
|
||||
[ '([0-9]+)b', gen_base64 ],
|
||||
[ '\^', gen_capitalize ],
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user