diff --git a/scripts/README.md b/scripts/README.md index d869df5..aaee09b 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -26,3 +26,7 @@ Description - tictactoe
A cli-based tictactoe game to play with the computer.
[Rounak Vyas](http://www.github.com/itsron717) + +- passwordgen
+ Generates a random password with minimun 8 digits.
+ [Akash Ramjyothi](https://github.com/Akash-Ramjyothi) diff --git a/scripts/passwordgen/README.md b/scripts/passwordgen/README.md new file mode 100644 index 0000000..0f35c80 --- /dev/null +++ b/scripts/passwordgen/README.md @@ -0,0 +1,5 @@ +# Password Generator +Generates a random password with minimun of 8 digits. + +## Usage +`python main.py` \ No newline at end of file diff --git a/scripts/passwordgen/main.py b/scripts/passwordgen/main.py new file mode 100644 index 0000000..63a8b7b --- /dev/null +++ b/scripts/passwordgen/main.py @@ -0,0 +1,33 @@ +import random, string, sys + +# List of characters, alphabets, numbers +# to choose from +data_set = list(string.ascii_letters) + list(string.digits) + list(string.punctuation) + +# generates a random password +# very strong due to random ness +# primary protection against dictionary attack on hash tables + +def generate_random_password(n): + # For password to be strong it should + # be at least 8 characters long + if n < 8: + return "Invalid Input,\nPassword should be at least 8 characters long!" + + # Chooses a random character from data_set + # after password of given length is created + # returns it to user + password = "" + for x in range(n): + password += random.choice(data_set) + + return password + +# Test + +while True: + usr = raw_input("Exit(press e), or Length: ").lower() + if usr == "e": + sys.exit() + + print("Generated password: " + generate_random_password(int(usr)) + "\n") \ No newline at end of file