Commit d5f657283b
Verified · cmc
Layout: unified · split
yoshi/process.py +4 −3
| @@ -25,6 +25,7 @@ Usage: | ||
| 25 | 25 | |
| 26 | 26 | from string import ascii_letters, punctuation, digits |
| 27 | 27 | import random |
| 28 | import secrets | |
| 28 | 29 | import uuid |
| 29 | 30 | from prettytable import PrettyTable |
| 30 | 31 | from yoshi.account import Account |
| @@ -45,7 +46,7 @@ def generate_characters(n: int) -> list: | ||
| 45 | 46 | characters = [] |
| 46 | 47 | password_format = ascii_letters + punctuation + digits |
| 47 | 48 | for _ in range(n): |
| 48 | characters.append(random.choice(password_format)) | |
| 49 | characters.append(secrets.choice(password_format)) | |
| 49 | 50 | return characters |
| 50 | 51 | |
| 51 | 52 | |
| @@ -76,9 +77,9 @@ def generate_passphrase(n: int, sep: str) -> str: | ||
| 76 | 77 | str: A string representation of the passphrase |
| 77 | 78 | """ |
| 78 | 79 | phrases = [] |
| 79 | lucky_number = random.choice(range(0, n)) | |
| 80 | lucky_number = secrets.choice(range(0, n)) | |
| 80 | 81 | for _ in range(n): |
| 81 | word = random.choice(WORDLIST) | |
| 82 | word = secrets.choice(WORDLIST) | |
| 82 | 83 | if _ == lucky_number: |
| 83 | 84 | phrases.append(word.capitalize() + str(_)) |
| 84 | 85 | else: |