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