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("Non è stato utilizzato alcun dizionario")
- no()
- while lll!="Y" and lll!="N" and lll!="y" and lll!="n":
- lll=input("Utilizzare "+g[ggg]+" come dizionario?[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("Inserire separatore parole:[n=a capo]")
- try:
- if b=="":
- 6/0
- except ZeroDivisionError:
- b=input("Devi inserire un separatore, se non esiste lasciare digitare INVIO senza scrivere niente: ")
- 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("Inserire numeri?[Y/N]")
- set1=set1.upper()
- while set2!="n" and set2!="N" and set2!="Y" and set2!="y":
- set2=input("Inserire lettere minuscole?[Y/N]")
- set2=set2.upper()
- while set3!="n" and set3!="N" and set3!="Y" and set3!="y":
- set3=input("Inserire maiuscole?[Y/N]")
- set3=set3.upper()
- while set4!="n" and set4!="N" and set4!="Y" and set4!="y":
- set4=input("Inserire caratteri speciali?[Y/N]")
- set4=set4.upper()
- try:
- set5=int(input("Inserire lunghezza password: "))
- except ValueError:
- set5=4
- try:
- set6=int(input("Inserire password da generare: "))
- 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("Questo dizionario non può essere utilizzato")
- 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("Questo dizionario non può essere utilizzato")
- os.rename("dic.txt",gdkj)
- b="N"
- while b!="Y" and b!="n" and b!="N" and b!="y" and b!=00:
- b=input("Utilizzare questo dizionario?[Y/N] ")
- if b=="y"or b=="Y":
- try:
- k=int(input("Inserire numero parole: "))
- if k<0:
- 6/0
- except ValueError:
- k=1
- except ZeroDivisionError:
- k=1
- kk=input("Inserire separatore parole: ")
- kkk=int(input("Inserire numero 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("Clicca per continuare")
- print("\n"*1000)
- while True:
- def startfunc():
- import glob
- zzz=""
- if zzz=="":
- print("Se si vuole utilizzare un dizionario:")
- print("Inserite nella cartella di questo script un file")
- print("con estensione txt contenente il dizionario")
- print("ogni parola deve essere separata col medesimo separatore")
- while zzz!="Y" and zzz!="N" and zzz!="y" and zzz!="n":
- zzz=input("Utilizzare un dizionario?[Y/N]")
- zzz.upper()
- import os
- if not(os.path.exists("dic.txt")) and zzz!="Y":
- pass
- clsdir()
- psw()
- startfunc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement