Last active
April 10, 2025 19:27
-
-
Save bergantine/1119284 to your computer and use it in GitHub Desktop.
Python Random Password Generator (One Liner). #python #password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -c "from random import choice; print ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789%^*(-_=+)') for i in range(32)])" |
For Python 3:
python -c "from random import choice; print(''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789%^*(-_=+)') for i in range(32)]))"
Seems that the link above was taken down, or is private.
i re-added the correct link for the gist.
Personally, i feel better if you changed this from from random import choice
to from secrets import choice
.
In the Docs, it says
The secrets module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets.
In particular, secrets should be used in preference to the default pseudo-random number generator in the random module, which is designed for modelling and simulation, not security or cryptography.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated for python 3.6
https://gist.github.com/urjeetpatel/60cee1e7dc509ead24e99f70de3b5bd7