krz/yoshi-cli

Archived

A password manager for the command line. cli password-manager terminal

Commit d5f657283b

d5f657283bc7de525661f3a967e5d6fb213763d2

parent: a7bf2c602b

Verified · cmc

cmc <hello@cleberg.net> · 2025-04-05 03:32 UTC

fix: replace random.choice with secrets.choice

Layout: unified · split

yoshi/process.py +4 −3
@@ -25,6 +25,7 @@ Usage:
25 25
26from string import ascii_letters, punctuation, digits 26from string import ascii_letters, punctuation, digits
27import random 27import random
28import secrets
28import uuid 29import uuid
29from prettytable import PrettyTable 30from prettytable import PrettyTable
30from yoshi.account import Account 31from 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: