Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion projects/Random_password_generator/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Python Password Generator
##### THIS SIMPLE PROJECT WAS MADE USING PYTHON LIBRARY FUNCTIONS LIKE `string` & `random`.
##### THIS SIMPLE PROJECT WAS MADE USING PYTHON LIBRARY FUNCTIONS LIKE `string` , `random` & `pyperclip`.

* `string.ascii_letters`
- The concatenation of the ascii_lowercase and ascii_uppercase constants described below. This value is not locale-dependent.
Expand All @@ -21,3 +21,22 @@ The string <kbd>01234567</kbd>.

* `string.punctuation`
- String of ASCII characters which are considered punctuation characters in the C locale: `!"#$%&'()*+,-./:;<=>?@[\]^_{|}~`


--------------------------
## Password Security Level

* `a`
- the password with ascii letters , digits & punctuation

* `b`
- the password with ascii letters & digits.

* `c`
- the password just with ascii letters .

* `d`
- the password with ascii lowercase & digits .

* `e`
- the password just with digits .
33 changes: 33 additions & 0 deletions projects/Random_password_generator/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from psw import password_generator, PasswordSecurityLevel as PSL
from pyperclip import copy

def main():
y = 'y'

print('Hello World !')
print('Wellcome to password generator')
print('------------------------------')

while(True):
level = input('\n < Enter level of password security > [a/b/c/d/e] : ')
lenght = int(input(' < Enter lenght of password > : '))
psw_level = PSL.get(level)

psw = password_generator(psw_level, lenght)

print(" < your random passwoed > : ", psw)

copy_condition = input(
" would you like to copy it in your clipboard ? [y/n] : ")
if copy_condition == y:
copy(psw)
print(' done!')

continue_condition = input(" continue ? [y/n] : ")
if continue_condition != y:
break

print('so long.')

if __name__ == '__main__':
main()
26 changes: 26 additions & 0 deletions projects/Random_password_generator/psw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from string import ascii_lowercase as lowercase
from string import ascii_uppercase as uppercase
from string import digits
from string import punctuation as spacial
from typing import Iterator

from toolbox import *


class PasswordSecurityLevel:
a = mixer(digits, lowercase, uppercase, spacial)
b = mixer(lowercase, uppercase, digits)
c = mixer(lowercase, uppercase)
d = mixer(digits, lowercase)
e = mixer(digits)

@classmethod
def get(cls, level: str) -> List:
""" return level by level title """
if len(level) == 1:
return cls.__dict__[level]


def password_generator(source: Iterable = PasswordSecurityLevel.a, lenght: int = 8) -> str:
password = ''.join(choice(source, lenght))
return password
10 changes: 0 additions & 10 deletions projects/Random_password_generator/python-password-generator.py

This file was deleted.

43 changes: 0 additions & 43 deletions projects/Random_password_generator/random_password_gen.py

This file was deleted.

Empty file.
12 changes: 12 additions & 0 deletions projects/Random_password_generator/toolbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from random import choices
from typing import Iterable, List


def mixer(*iterators: Iterable) -> List:
""" merge itrators to one itrator """
return list(value for row in zip(*iterators) for value in row)


def choice(iterator: Iterable, count: int) -> List:
""" shortcut for random.choices """
return choices(iterator, k=count)
1 change: 1 addition & 0 deletions requirementsALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ wikipedia==1.4.0
win10toast==0.9
wordcloud==1.8.0
xmltodict==0.12.0
pyperclip==1.8.2