38
votes
Accepted
Random password generator in C
I see some things that I think could help you improve your code.
Decompose your program into functions
All of the logic here is in main in one rather long and ...
29
votes
Accepted
My first random password generator
Typo
lenght is spelled length.
Magic numbers
What does 95 signify? You'll want to put ...
25
votes
Random alphanumeric password generator with GOTOs
Data structure
Why are you using a LinkedList<char>? Linked lists involve a lot of overhead for each node. You know exactly how long the result should be, ...
24
votes
Password generator in python
The other answers have great hints that you should definitely follow.
However, since we are talking about passwords here, a little bit of extra security might not hurt. Especially if it's readily ...
20
votes
Accepted
Python \ random password generation code
Don't use random for security
Quoting from the documentation for random:
Warning: The pseudo-random generators of this module ...
19
votes
Python password generator class
Please
don't
use
random
for
password
generation
in
Python.
Use secrets like this. This has been covered (again, and again, times ...
18
votes
Accepted
Python command-line program that generates passwords
Put all code in functions. Code in functions can be tested, experimented
with, and reorganized much more easily than code floating around at the top
level. Floating code introduces the temptation to ...
17
votes
Accepted
Python password generator class
It's clean and readable, the logic is sensible and easy to follow, and I do like seeing type signatures
I do think the structure can be improved, however - a class with only ...
16
votes
Typical password generator in Python
Character Sets
The code assumes you only want passwords using the Latin alphabet, the Arabic numerals, and some ASCII special characters. Being locked into the character set has three main problems:
...
Community wiki
15
votes
Accepted
A password generator
One of the easiest ways to improve code is to reduce repetition. The
most-repeated elements in your code are random.choice and ...
15
votes
A password generator
Don't use random.choice() for generating passwords. As the documentation says:
Warning: The pseudo-random generators of this module should not be used for ...
15
votes
Python command-line program that generates passwords
I feel like you came up with an over-engineered solution that, ultimately, fails to meet expectations.
Generating a password is a task with well-defined use-cases, that we encounter almost daily.
Most ...
14
votes
Random alphanumeric password generator with GOTOs
Readability & GoTo
If you want to do the same action for 3 different if-statements make them one if-statement or make them a function. goto causes massive ...
14
votes
Accepted
Password generator in python
Refactoring in steps
Enumeration class
Types is too generic name for the enum representing char types. Renamed to CharTypes.
...
14
votes
Random password generator in C
There is a bug in this line:
password[i] = symbols[rand() % 26];
symbols is only 21 characters long, so this line triggers ...
14
votes
Accepted
Beginner level password generator optimization
Remarks:
Bug: you have an extra letter sneaking in with for req in range(0, nr_letters + 1):, making your output longer than it should be. That should be ...
11
votes
My first random password generator
Whilst your code works, there are a number of simplifications that you might try.
As Reinderien says, get rid of "magic" numbers
Having done that, declare a single string containing all 95 characters ...
11
votes
Random alphanumeric password generator with GOTOs
Avoid premature optimizations, they're really hurting this code.
In the comments you defend the use of goto using the argument that it avoids branch prediction.
...
10
votes
Random password generator in C
I don't know if this is just an exercise to learn about working with strings and numbers, or if you ever intend to use this to generate real passwords. But if you do, this line can be a serious ...
10
votes
10
votes
Beginner level password generator optimization
Security
The documentation for the random module gives the following warning:
Warning: The pseudo-random generators of this module should not be used for security ...
9
votes
Password Generator "Crapcode"
From MSDN Random class documentation
To generate a cryptographically secure random number, such as one that's suitable for creating a random password, use the RNGCryptoServiceProvider class or derive ...
8
votes
Random alphanumeric password generator with GOTOs
In this case, if performance are not a MEASURED issue (read: you're not generating 1,000,000 passwords) then I'd definitely pick the most readable version.
It might even be something like this (...
8
votes
Does my passwords generator in C# make sense?
Problem Size
This is an exponential problem in passwordLength. Your on-screen output and file output is going to take a maximum of 62^7 = 3,521,614,606,208 words, ...
8
votes
Python password generator class
Good use of type annotations!
Variable and method naming is mostly concise and readable.
password_level: week should be ...
8
votes
Python \ random password generation code
As a general principle, humans are very bad at generating "random" sequences. And that's where automated password generators come in place.
Unfortunately, your algorithm has some very ...
7
votes
Secure random password generator
Top hit on Google looks very similar; in any case no need to reinvent this.
But really, if this is the initial password, the users are going to get it how? Are the being forced to reset it ...
7
votes
My first random password generator
You could get away without all the complicated memory allocation if you simply require that the calling code passes you the memory for the password. It could look like this:
...
7
votes
Random password generator in C
Take this line from every branch and put it at the end of the loop:
printf("%c", password[i]);
Take this from every branch and put it at the start of the loop (and ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
password-generator × 68python × 34
random × 21
python-3.x × 19
security × 12
java × 11
beginner × 11
strings × 9
c# × 6
console × 6
c++ × 5
object-oriented × 4
c × 3
swing × 3
tkinter × 3
performance × 2
classes × 2
javascript × 1
php × 1
html × 1
c++11 × 1
design-patterns × 1
python-2.x × 1
haskell × 1
comparative-review × 1