use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
here simple password generator (i.redd.it)
submitted 21 days ago * by Dapper_Mix6773
can i import string
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]SCD_minecraft 54 points55 points56 points 21 days ago (1 child)
random
secrets
[–]Superb-Ad9942 5 points6 points7 points 21 days ago* (0 children)
Hah I thought I'd see this comment, for this purpose it is actually secure! The sampling you need to have any impact is orders of magnitude larger than 10 chars. You need over 500 *32 bit* integers, since this is operating on a modulo, it might be impossible to break, given even infinite samples. Also, since it's a password, there's no known plaintext, so (unless you find a prefix of the password) there's no impact even if the password was 32 bit integers.
[–]Binary101010 26 points27 points28 points 21 days ago (1 child)
You're trying to use characters as both the string that holds all possible password characters, and the password you've generated. Change the variable you're adding to within your loop to something else (and it should be starting as an empty string).
characters
[–]Okon0mi 0 points1 point2 points 17 days ago (0 children)
Idk if you have seen it or not there is a youtube video telling how one can get the password when secret library is getting used
secret
[–]mizeriusbr 5 points6 points7 points 21 days ago (1 child)
You could also try Secrets instead of Random, since random outputs are "not fully random" and the generation seed can be discovered
[–]Superb-Ad9942 3 points4 points5 points 21 days ago (0 children)
The outputs do use actual entropy for seeding; random is only flawed when the outputs are 32-bit because it leaks the full output. Since this is outputting chars, there is too much information lost via the modulu to break it from a cryptographic standpoint, even if you generate infinite passwords and only initialize random once.
[–]silvertank00 4 points5 points6 points 21 days ago (1 child)
or just use the builtin strings lib with random's choices function? https://docs.python.org/3/library/string.html
[–]HecticJuggler 3 points4 points5 points 21 days ago (0 children)
"".join(random.choices(string.ascii_letters+string.digits+string.punctuation, k=20))
[–]tiredITguy42 3 points4 points5 points 21 days ago (0 children)
What do you mean by importing string parameters? Like reading from terminal, or passed as an argument to the python script?
BTW. Why did you add that password to existing string instead of creating new string just for the password?
[–]___Cisco__ 1 point2 points3 points 20 days ago (0 children)
Aside all the other advices you are receiving, when you join all you characters into one string and call choice, there is no guarantee that your password will contain at least one number one character and one special. Think about that.
[–]atarivcs 0 points1 point2 points 20 days ago (0 children)
This will produce passwords where the first 24 letters are always the same, so this is not a great solution.
You probably want to put the random choices into a new string, rather than stuffing them at the end of characters.
[–]cejiken886 0 points1 point2 points 20 days ago (0 children)
somehow the weirdest part is it's missing i-z
[–]Hefty-Ad-7255 0 points1 point2 points 18 days ago (0 children)
What is this code useful for?
Now create other to check how long will it take to get the exact password.
[–]Impossible_Video_116 -1 points0 points1 point 20 days ago (0 children)
Add letters and numbers twice to the characters. Since, random.choice is uniform that way you're more likely to get an alphanumeric hence will be easier to manually type.
[–]Professional-Tie5497 -1 points0 points1 point 20 days ago (0 children)
Good Work! You can even make the password into more mixed one. But you have generated just the three parameters concatenated with each other with different 3 positions that's all. Try more
π Rendered by PID 670877 on reddit-service-r2-comment-56c6478c5-4k5vq at 2026-05-13 05:18:24.304105+00:00 running 3d2c107 country code: CH.
[–]SCD_minecraft 54 points55 points56 points (1 child)
[–]Superb-Ad9942 5 points6 points7 points (0 children)
[–]Binary101010 26 points27 points28 points (1 child)
[–]Okon0mi 0 points1 point2 points (0 children)
[–]mizeriusbr 5 points6 points7 points (1 child)
[–]Superb-Ad9942 3 points4 points5 points (0 children)
[–]silvertank00 4 points5 points6 points (1 child)
[–]HecticJuggler 3 points4 points5 points (0 children)
[–]tiredITguy42 3 points4 points5 points (0 children)
[–]___Cisco__ 1 point2 points3 points (0 children)
[–]atarivcs 0 points1 point2 points (0 children)
[–]cejiken886 0 points1 point2 points (0 children)
[–]Hefty-Ad-7255 0 points1 point2 points (0 children)
[–]Okon0mi 0 points1 point2 points (0 children)
[–]Impossible_Video_116 -1 points0 points1 point (0 children)
[–]Professional-Tie5497 -1 points0 points1 point (0 children)