Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Development #13

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
48 changes: 48 additions & 0 deletions projects/Random password generator/random_password_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import random
import math
alpha="abcdefghijklmnopqrstuvwxyz"
num="0123456789"
special="@#$%&*"

#pass_len=random.randint(8,13) #without User INput
pass_len=int(input("Enter Password Length"))

#length of password by 50-30-20 formula
alpha_len=pass_len//2
num_len=math.ceil(pass_len*30/100)
special_len=pass_len-(alpha_len+num_len)


password=[]

def generate_pass(length,array,is_alpha=False):

for i in range(length):
index=random.randint(0,len(array)-1)
character=array[index]
if is_alpha==True:

case=random.randint(0,1)
if case==1:
character=character.upper()

password.append(character)

#alpha password
generate_pass(alpha_len,alpha,True)
#numeric password
generate_pass(num_len,num)
#special Character password
generate_pass(special_len,special)

#suffle the generated password list
random.shuffle(password)

#convert List To string
gen_password=""
for i in password:
gen_password=gen_password+str(i)

print(gen_password)


Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Files-Sorter
This is python script that sort the files in Download directory to other directories depending on extention.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import shutil
os.chdir("E:\downloads")
#print(os.getcwd())

#check number of files in directory
files = os.listdir()

#list of extension (You can add more if you want)
extentions = {
"images": [".jpg", ".png", ".jpeg", ".gif"],
"videos": [".mp4", ".mkv"],
"musics": [".mp3", ".wav"],
"zip": [".zip", ".tgz", ".rar", ".tar"],
"documents": [".pdf", ".docx", ".csv", ".xlsx", ".pptx", ".doc", ".ppt", ".xls"],
"setup": [".msi", ".exe"],
"programs": [".py", ".c", ".cpp", ".php", ".C", ".CPP"],
"design": [".xd", ".psd"]


}


#sort to specific folder depend on extenstions
def sorting(file):
keys = list(extentions.keys())
for key in keys:
for ext in extentions[key]:
# print(ext)
if file.endswith(ext):
return key


#iterat through each file
for file in files:
dist = sorting(file)
if dist:
try:
shutil.move(file, "../download-sorting/" + dist)
except:
print(file + " is already exist")
else:
try:
shutil.move(file, "../download-sorting/others")
except:
print(file + " is already exist")