Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request #4 from ArjunSharda/randomlibcriticalpatch
Security patch + quickgen command
  • Loading branch information
ArjunSharda committed Dec 6, 2022
2 parents d51dd9f + 212f067 commit 8caa798
Showing 1 changed file with 50 additions and 22 deletions.
72 changes: 50 additions & 22 deletions src/passeo/__init__.py
@@ -1,32 +1,36 @@
import random
import string
import hashlib
import requests
import secrets


class passeo:
def __init__(self):

def generate(length, numbers=False, symbols=False, uppercase=False, lowercase=False, space=False, save=False):
password = ''
if numbers:
password += string.digits
if symbols:
password += string.punctuation
if uppercase:
password += string.ascii_uppercase
if lowercase:
if uppercase:
raise ValueError('Uppercase and lowercase are both true, please make one of them false.')
password += string.ascii_lowercase
if space:
if numbers is True:
password += secrets.choice(string.digits)
if symbols is True:
password += secrets.choice(string.punctuation)
if lowercase and uppercase == True:
raise ValueError('Uppercase and lowercase are both true, please make one of them false.')

if uppercase is True:
password += secrets.choice(string.ascii_uppercase)
if lowercase is True:
password += secrets.choice(string.ascii_lowercase)


if space is True:
password += ' '
PasseoPassword = ''.join(random.sample(password, length))
if save:
PasseoPassword = ''.join(secrets.choice(password) for i in range(length))
if save is True:
with open('passeo_passwords.txt', 'a') as file:
file.write(PasseoPassword + '\n')
return PasseoPassword


self.generate = generate

def strengthcheck(password):
Expand All @@ -47,27 +51,51 @@ def strengthcheck(password):
elif y == None:
StrengthCheckQuiz['Pwned'] = '1/3: FAIL: An error has occurred, please try again.'
if length < 8:
StrengthCheckQuiz['Length'] = '2/3: FAIL: Your password is too short, it is recommended to make it longer.'
StrengthCheckQuiz[
'Length'] = '2/3: FAIL: Your password is too short, it is recommended to make it longer.'

elif length >= 8 and length <= 16:
StrengthCheckQuiz['Length'] = '2/3: PASS: Your password is long enough! It could be longer, but is great.'
StrengthCheckQuiz[
'Length'] = '2/3: PASS: Your password is long enough! It could be longer, but is great.'

elif length > 16:
StrengthCheckQuiz['Length'] = '2/3: PASS: Your password is very long, good job!'

elif length == None:
StrengthCheckQuiz['Length'] = '2/3: FAIL: An error has occurred, please try again.'

if password.lower():
StrengthCheckQuiz['Case'] = '3/3: FAIL: Your password has lowercase letters, but not uppercase letters, it is recommended to add uppercase letters.'
StrengthCheckQuiz[
'Case'] = '3/3: FAIL: Your password has lowercase letters, but not uppercase letters, it is recommended to add uppercase letters.'

elif password.upper():
StrengthCheckQuiz['Case'] = '3/3: FAIL: Your password has uppercase letters, however it is also recommended to add lowercase letters.'
StrengthCheckQuiz[
'Case'] = '3/3: FAIL: Your password has uppercase letters, however it is also recommended to add lowercase letters.'
elif password.lower() and password.upper():
StrengthCheckQuiz['Case'] = '3/3: PASS: Your password has both uppercase and lowercase letters, good job!'

StrengthCheckQuiz[
'Case'] = '3/3: PASS: Your password has both uppercase and lowercase letters, good job!'

elif password == None:
StrengthCheckQuiz['Case'] = '3/3: FAIL: An error has occurred, please try again.'
return str(StrengthCheckQuiz['Pwned']) + '\n' + str(StrengthCheckQuiz['Length'] + '\n' + str(StrengthCheckQuiz['Case']) + '\n' + 'The Passeo password strength test has ended. Any questions/bugs? Raise a issue on https://github.com/ArjunSharda/Passeo/issue.')
return str(StrengthCheckQuiz['Pwned']) + '\n' + str(StrengthCheckQuiz['Length'] + '\n' + str(
StrengthCheckQuiz[
'Case']) + '\n' + 'The Passeo password strength test has ended. Any questions/bugs? Raise a issue on https://github.com/ArjunSharda/Passeo/issue.')

self.strengthcheck = strengthcheck

def quickgenerate(length=int, save=False, bulk=1):
PASSEO_QUICKGEN_PASSWORD = ''.join(
secrets.choice(string.ascii_letters + string.digits) for i in range(length))
if save:
with open('passeo_quickgen_passwords.txt', 'a') as file:
file.write(PASSEO_QUICKGEN_PASSWORD + '\n')
if bulk > 1:
with open('passeo_quickgen_bulk_passwords.txt', 'a') as bulkf:
for i in range(bulk):
bulkf.write(''.join(
secrets.choice(string.ascii_letters + string.digits) for i in range(length)) + '\n')

return PASSEO_QUICKGEN_PASSWORD


self.quickgenerate = quickgenerate

0 comments on commit 8caa798

Please sign in to comment.