Skip to main content
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 ...
Edward's user avatar
  • 67.2k
29 votes
Accepted

My first random password generator

Typo lenght is spelled length. Magic numbers What does 95 signify? You'll want to put ...
Reinderien's user avatar
  • 71.1k
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, ...
200_success's user avatar
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 ...
AlexV's user avatar
  • 7,363
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 ...
gazoh's user avatar
  • 3,399
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 ...
Reinderien's user avatar
  • 71.1k
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 ...
FMc's user avatar
  • 13.1k
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 ...
Sara J's user avatar
  • 4,221
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: ...
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 ...
FMc's user avatar
  • 13.1k
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 ...
Toby Speight's user avatar
  • 88.3k
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 ...
gazoh's user avatar
  • 3,399
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 ...
Shelby115's user avatar
  • 1,971
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. ...
RomanPerekhrest's user avatar
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 ...
trent's user avatar
  • 1,124
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 ...
ggorlen's user avatar
  • 4,167
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 ...
Peter Jennings's user avatar
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. ...
Morgen's user avatar
  • 691
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 ...
Thomas Padron-McCarthy's user avatar
10 votes

First password generator in Python

...
benrg's user avatar
  • 486
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 ...
gazoh's user avatar
  • 3,399
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 ...
radarbob's user avatar
  • 8,249
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 (...
Adriano Repetti's user avatar
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, ...
Neil's user avatar
  • 1,112
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 ...
riskypenguin's user avatar
  • 3,493
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 ...
Martin Baulig's user avatar
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 ...
ferada's user avatar
  • 11.4k
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: ...
Roland Illig's user avatar
  • 21.9k
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 ...
Miron's user avatar
  • 418

Only top scored, non community-wiki answers of a minimum length are eligible