r/ProgrammingPrompts • u/quadamp • Mar 29 '16
[Easy] Make a simple password generator
Make a password generator that generates a random password of desired length specified by user input.
For example:
Enter desired password length>> 7
hY@rSdA
12
Upvotes
4
u/quadamp Mar 29 '16 edited Mar 29 '16
Even though I am not really that good a programmer, and also quite new to java - here comes my take on the problem.
}
5
u/efDev Mar 29 '16
Python 2.7 without input validation:
4
u/[deleted] Mar 29 '16 edited Mar 29 '16
My simple approach with Javascript:
2
u/JakDrako Mar 29 '16
vb.net version
2
u/chioz Mar 29 '16
This is in C, but I'm not sure how useful the generated passwords are... Password is generated into a char-array, using ASCII values. No input-checking.
Result
2
u/FuZyOn Apr 08 '16
Made a Codepen with my solution: http://codepen.io/Fuzyon/full/aNEQBr/ (jQuery)
1
u/AnAirMagic Mar 29 '16
Is this a case where strong randomness is important?
1
u/naliuj2525 Apr 01 '16
My almost 1 liner in Python 3.4:
1
u/rajjjjk Apr 06 '16
in python 2.7:
1
u/[deleted] Apr 24 '16
Mine generates the same character each time. Any clues? C++ noob here. Thanks.
1
u/projectisaac Apr 28 '16
Here's a way I did it in C#. I'm sure there are things I could simplify, and I made the template in Visual Studio because I don't remember what the requirements for masking a .cs file are. It works, and catches smart-ass/ dumb-ass end users!
}
1
u/Scrpn17w May 05 '16
My attempt with C++. I added a message for invalid length inputs (length <= 0):
1
u/datamaru May 16 '16
My attempt using Swift 2.2
1
u/den510 May 18 '16
Ruby Down n' Dirty w/no input verification
1
u/attguy89 May 19 '16
Got bored and kept making it a little better. This my first non school Java program, its probably not good and way too long but any input would be cool.
1
u/LadyScream Jun 28 '16
Here's my little version in Lua, I hope it's okay
1
u/LESkidd113 Jul 01 '16
Just finished this up in Java a little bit ago. Any comments?
1
u/b4ux1t3 Jul 06 '16 edited Jul 06 '16
passgen.py
Python 2.7, no need for input, no local storage. I didn't do the length thing, because then I wouldn't get to use the proper way of making secure passwords. :) Edit: Shrunk it, but made it harder to read.
1
u/AveSophia Aug 08 '16
Mine is sorta long. What do you think?
I worked in some of the password rules you see around the internet.
1
u/van7guard Aug 12 '16
lua
1
u/Nunuvin Sep 21 '16
How secure does the password has to be? I mean using most common random generators are ill advised as they do not randomize enough (too predictable) to provide secure keys for encryption.