File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -68,13 +68,14 @@ def create_backup(self):
6868 json .dump (self .pw_dict , pw_file_json )
6969
7070 @staticmethod
71- def generate_random_password (special_characters = True ):
72- """Generates a random password with 42 characters of any type (letters, digits, special characters)."""
71+ def generate_random_password (special_characters = True ,
72+ password_length : int = 42 ) -> str :
73+ """Generates a random password and returns it as a string."""
7374 digits = string .digits
7475 letters = string .ascii_letters
7576 punctuation = r"!#$%&()*+:,-./;<=>?@[]^_{|}~" if special_characters else None
7677 characters = digits + letters + punctuation
77- random_password = '' .join (random .choice (characters ) for i in range (42 ))
78+ random_password = '' .join (random .choice (characters ) for i in range (password_length ))
7879 return random_password
7980
8081 @staticmethod
Original file line number Diff line number Diff line change @@ -92,7 +92,10 @@ def main(parsed_args):
9292 return pw .create_section (args .section )
9393
9494 if args .generate_random_pw :
95- random_pw = pw .generate_random_password ()
95+ if args .input is not None :
96+ random_pw = pw .generate_random_password (password_length = int (args .input ))
97+ else :
98+ random_pw = pw .generate_random_password ()
9699 return pw .copy_and_print_pw (random_pw )
97100
98101 if args .input is None :
You can’t perform that action at this time.
0 commit comments