EasyPro challengePython

Fix Insecure Randomness

PythonSecurityRandomness

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

Test #1Single token has correct shape
Input: [1]
Output: {"count":1,"all_hex":true,"all_unique":true,"all_correct_length":true}
Test #2Five tokens, all correctly formed and unique
Input: [5]
Output: {"count":5,"all_hex":true,"all_unique":true,"all_correct_length":true}
Test #3Zero tokens is a trivially valid edge case
Input: [0]
Output: {"count":0,"all_hex":true,"all_unique":true,"all_correct_length":true}