The function below generates "unique" tokens using random.randint, producing short, low-entropy decimal strings instead of proper session tokens.
The bug: Python's random module uses the Mersenne Twister — fast, but not cryptographically secure. Its output is predictable if an attacker observes enough samples, and it isn't designed to produce fixed-length, uniformly-distributed tokens. For anything security-sensitive (session IDs, password reset tokens, API keys), this is the wrong tool.
Your task: fix solve(n) to generate n tokens using the secrets module — Python's cryptographically secure random generator — and return a summary of their properties.
solve(5)
# → {'count': 5, 'all_correct_length': True, 'all_hex': True, 'all_unique': True}Sample tests