Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def clsdir():
- import os,glob
- lll=""
- g=glob.glob("*.txt")
- gg=len(g)-1
- ggg=0
- while True:
- if ggg==gg+1:
- print("\n"*1000)
- print("Have not used any dictionary")
- no()
- while lll!="Y" and lll!="N" and lll!="y" and lll!="n":
- lll=input("Use "+g[ggg]+" as dictionary?[Y/N]")
- if lll=="y" or lll=="Y":
- if g[ggg]=="dic.txt":
- psw()
- else:
- break
- else:
- ggg=ggg+1
- lll=""
- if os.path.exists(g[ggg]):
- d=open(g[ggg],"r")
- a=d.read()
- b=input("Insert separator words: [n = head]")
- try:
- if b=="":
- 6/0
- except ZeroDivisionError:
- b=input("You must enter a separator, if there leave type ENTER without typing anything: ")
- if b=="":
- psw()
- if b=="n":
- b="\n"
- a=a.replace(b,"|")
- k=open("dic.txt","x")
- k.write(a)
- def no():
- pas=set1=set2=set3=set4=set5=log=""
- while set1!="n" and set1!="N" and set1!="Y" and set1!="y":
- set1=input("Enter numbers?[Y/N]")
- set1=set1.upper()
- while set2!="n" and set2!="N" and set2!="Y" and set2!="y":
- set2=input("Enter lowercase?[Y/N]")
- set2=set2.upper()
- while set3!="n" and set3!="N" and set3!="Y" and set3!="y":
- set3=input("Enter uppercase?[Y/N]")
- set3=set3.upper()
- while set4!="n" and set4!="N" and set4!="Y" and set4!="y":
- set4=input("Insert special characters?[Y/N]")
- set4=set4.upper()
- try:
- set5=int(input("Enter password length: "))
- except ValueError:
- set5=4
- try:
- set6=int(input("Enter password to generate: "))
- except ValueError:
- set6=1
- if set1=="N" and set2=="N" and set3=="N" and set4=="N" :
- set1="Y"
- for j in range(set6):
- while len(pas)!=set5:
- rndset=random.randint(1,4)
- if rndset==1 and set1=="Y":
- log=random.randint(1,10)
- log=string.digits[log-1]
- if rndset==2 and set2=="Y":
- log=random.randint(1,26)
- log=string.ascii_lowercase[log-1]
- if rndset==3 and set3=="Y":
- log=random.randint(1,26)
- log=string.ascii_uppercase[log-1]
- if rndset==4 and set4=="Y":
- log=random.randint(1,32)
- log=string.punctuation[log-1]
- pas=pas+log
- log=""
- print(pas)
- pas=""
- def psw():
- import random,os,string
- b=n=""
- z=[]
- if os.path.exists("dic.txt"):
- try:
- a=open("dic.txt","r")
- except MemoryError:
- import random
- gdkj=random.randint(0,9999999999)
- gdkj="dic"+str(gdkj)+".txt"
- print("This dictionary can not be used")
- os.rename("dic.txt",gdkj)
- b="N"
- cache=a.read()
- cache=cache.split("|")
- if len(cache)==1:
- a.close()
- try:
- 6/0
- except ZeroDivisionError:
- import random
- gdkj=random.randint(0,9999999999)
- gdkj="dic"+str(gdkj)+".txt"
- print("This dictionary can not be used")
- os.rename("dic.txt",gdkj)
- b="N"
- while b!="Y" and b!="n" and b!="N" and b!="y" and b!=00:
- b=input("Use this dictionary?[Y/N] ")
- if b=="y"or b=="Y":
- try:
- k=int(input("Insert number words: "))
- if k<0:
- 6/0
- except ValueError:
- k=1
- except ZeroDivisionError:
- k=1
- kk=input("Insert separator words: ")
- kkk=int(input("Insert number password: "))
- for tm in range(kkk):
- for m in range(k):
- b=random.randint(1,len(cache))
- b=cache[b-1]
- if n!="":
- n=n+kk+b
- else:
- n=n+b
- print(n)
- n=""
- #---------------
- else:
- no()
- else:
- no()
- input("Click to continue")
- print("\n"*1000)
- def algos():
- try:
- import os,random,string
- a=b=c=d=var=code=finish=""
- e=f=0
- dic=[]
- print("n = Number")
- print("u = Uppercase")
- print("c = Lowercase")
- print("l = Special")
- print("p = Personal")
- print("s = Separator")
- print("Enter the number of characters")
- print("Example code: 2n3c")
- print("It will generate passwords with 2 numbers and 3 lowercase")
- a=input("Insert code: ")
- a=a.lower()
- error="abdefghijkmoqrtvwxyz"
- for err in error:
- if a.count(err)!=0:
- 6/0
- if a.count("n")==0 and a.count("u")==0 and a.count("c")==0 and a.count("l")==0 and a.count("p")==0 and a.count("s")==0:
- 6/0
- if a.count("s")!=0:
- b=input("Insert separator: ")
- if a.count("p")!=0:
- c=input("Insert personal characters: ")
- d=input("Insert number of password: ")
- if d=="":
- d="1"
- while True:
- if e==len(a):
- break
- else:
- if a[e]=="0" or a[e]=="1" or a[e]=="2" or a[e]=="3" or a[e]=="4" or a[e]=="5" or a[e]=="6" or a[e]=="7" or a[e]=="8" or a[e]=="9":
- var=var+a[e]
- else:
- try:
- code=code+(a[e]*int(var))
- except ValueError:
- code=code+(a[e]*1)
- var=""
- e=e+1
- for kk in range(int(d)):
- finish=""
- for nn in code:
- if nn=="n":
- ran=random.randint(0,9)
- finish=finish+string.digits[ran]
- if nn=="u":
- ran=random.randint(0,25)
- finish=finish+string.ascii_uppercase[ran]
- if nn=="c":
- ran=random.randint(0,25)
- finish=finish+string.ascii_lowercase[ran]
- if nn=="l":
- ran=random.randint(0,31)
- finish=finish+string.punctuation[ran]
- if nn=="p":
- ran=random.randint(0,len(c)-1)
- finish=finish+c[ran]
- if nn=="s":
- finish=finish+b
- print(finish)
- except ZeroDivisionError:
- print("Insert the code in correct format")
- while True:
- input("ENTER to continue")
- print("\n"*1000)
- def startfunc():
- import glob
- zzz=""
- if zzz=="":
- print("If you want to use a dictionary:")
- print("Place a file in the folder of this script")
- print("with extension .txt containing the dictionary")
- print("every word must be separated with the same separator")
- print("1 = Use a dictionary")
- print("2 = Create a random password")
- print("3 = Create a not random password")
- while zzz!="1" and zzz!="2" and zzz!="3":
- zzz=input("Choose what kind of password use: ")
- zzz.upper()
- if zzz=="2":
- no()
- import os
- if not(os.path.exists("dic.txt")) and zzz!="1":
- clsdir()
- psw()
- if zzz=="3":
- algos()
- startfunc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement