-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
PasswordGenerator.py #4873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
PasswordGenerator.py #4873
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# The main purpose of this is to get secure password to defend against Bruteforce attacks. | ||
|
||
|
||
import string | ||
import random | ||
import re | ||
|
||
if __name__ == '__main__': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What kind of algorithm is that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The algorithm should be a function that returns a password (str) and does not print(). See CONTRIBUTING.md |
||
s1 = string.ascii_uppercase # including uppercase letters to the set. | ||
|
||
s2 = string.ascii_lowercase # including lowercase letters to the set. | ||
|
||
s3 = string.digits # including digits to the set. | ||
|
||
s4 = string.punctuation # including symbols to the set. | ||
|
||
# declaring password length that useer will give for password generation. | ||
passlen = input("Enter password length max: 2 digit. \n") | ||
num_format = re.compile(r'[1-9][0-9]*$') | ||
it_is = re.match(num_format, passlen) | ||
|
||
if it_is: | ||
print("True") | ||
new_length= int(passlen) # The input() will take it as string but we change it to int because we are storing lenght. | ||
s = [] # creating our sets of numberals , alphabets and symbols. | ||
|
||
s.extend(list(s1)) # adding the elements of s1 to the set s. | ||
s.extend(list(s2)) # adding the elements of s2 to the set s. | ||
s.extend(list(s3)) # adding the elements of s3 to the set s. | ||
s.extend(list(s4)) # adding the elements of s4 to the set s. | ||
|
||
# It shuffles our set 's' so that each and everytime we ue we get different password. | ||
random.shuffle(s) | ||
|
||
print("The password is : \n") | ||
print("".join(s[0:new_length])) # prints the password upto passlen= new length now. | ||
|
||
else: | ||
|
||
print(" Not a Valid lenght") | ||
# int() will handle gibberish and throw error. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This repo requires that Python files are placed in an existing directory. See CONTRIBUTING.md.