Password generator in Python: random against secrets
One module separates these, and the captured output is the argument: both print an equally scrambled string, so running them tells you nothing about which one you can rely on. random is seeded from the OS at import, so Version A varies between runs too. It is unpredictable to a reader and reconstructible to an observer, which is exactly what makes it hard to catch.
VERSION A — INSECURE
password-random.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Version A — insecure
$ python3 --version
Python 3.14.6$ python3 password-random.py
eLwHpk9WgNnHGTlHVERSION B — CORRECT
Two hunks separate the two files; they are identical everywhere the diff does not mark. Their documentation blocks differ as well, compared above.
Version A — insecure Version B — correct
Documentation block: 9 lines removed, 12 added
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Difference: 3 lines removed, 3 lines added.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Version B — correct
$ python3 --version
Python 3.14.6$ python3 password-secrets.py
iOdOmqikpa00K57bNEXT
This file accompanies LLMs Can Write Code, but Cannot Read Your Mind, which is where the claim it checks is made.
ALL SOURCE EXHIBITS →