bybo Posted September 24, 2015 Report Posted September 24, 2015 (edited) Salut RST astazi vreau sa va prezint un script care genereaza o parola random Link Download: http://www.mediafire.com/downloa?d/2lnchenat14la0h/Password+genera?tor.zip Source Code:EDIT: import stringimport randomdef id1(size=3, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase): return ''.join(random.choice(chars) for c in range(size))def id2(size=5, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase): return ''.join(random.choice(chars) for c in range(size))def id3(size=8, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase): return ''.join(random.choice(chars) for c in range(size))def id4(size=12, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase): return ''.join(random.choice(chars) for c in range(size))print """Welcome to PassCreator v1.0 by PukaHere u can select how many caracters your password gonna have ex: 5 Char.=1xgf5--------------------------------------------------------------------------------1.Password with 3 characters2.Password with 5 characters3.Password with 8 characters4.Password with 12 characters"""c = input ("Type your option(1/2/3/4): ")password = ""if c == 1: password = id1() print passwordif c == 2: password = id2() print passwordif c == 3: password = id3() print passwordif c == 4: password = id4() print passwordm = raw_input("Do you wish to save the password?(y/n)")print mif m == 'y' or m == 'Y': with open ("passlog.txt", "a") as file: file.write('Your generated password is : ' + str(password) + "\n")In mare parte e facut de manutele mele dar si cu mult ajutor din partea lui Psiho, mrgrj, gecko si inca un baiat Edited November 14, 2015 by bybo Quote
Active Members MrGrj Posted September 24, 2015 Active Members Report Posted September 24, 2015 (edited) Ce-ai ma ?Eu nu te-am ajutat niciodata sa convertesti un string iar in string:AKA:m = [B]raw_input[/B]("Do you wish to save the password?(y/n)") # asta e deja string (ti-am explicat de 10 ori cel putin, mi-e martor tot chatu')Si acum pui conditite (ca sa fii tu sigur ca e string):if [B]str[/B](m) == 'y' or [B]str[/B](m) == 'Y'Spor la invatat in continuare though PS: In python 3.x raw_input() devine input() iar input()-ul din 2.x a fost removed. Edited September 24, 2015 by MrGrj Quote
Ganav Posted September 24, 2015 Report Posted September 24, 2015 Salut RST astazi vreau sa va prezint un script care genereaza o parola random Link Download: http://www.mediafire.com/downloa?d/2lnchenat14la0h/Password+genera?tor.zip Source Code: import stringimport randomdef id1(size=3, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase): return ''.join(random.choice(chars) for c in range(size))def id2(size=5, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase): return ''.join(random.choice(chars) for c in range(size))def id3(size=8, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase): return ''.join(random.choice(chars) for c in range(size))def id4(size=12, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase): return ''.join(random.choice(chars) for c in range(size))print """Welcome to PassCreator v1.0 by PukaHere u can select how many caracters your password gonna have ex: 5 Char.=1xgf5--------------------------------------------------------------------------------1.Password with 3 characters2.Password with 5 characters3.Password with 8 characters4.Password with 12 characters"""c = input ("Type your option(1/2/3/4): ")password = ""if c == 1: password = id1() print passwordif c == 2: password = id2() print passwordif c == 3: password = id3() print passwordif c == 4: password = id4() print passwordm = raw_input("Do you wish to save the password?(y/n)")print str(m)if str(m) == 'y' or str(m) == 'Y': with open ("passlog.txt", "w") as file: file.write('Your generated password is : ' + str(password))In mare parte e facut de manutele mele dar si cu mult ajutor din partea lui Psiho, mrgrj, gecko si inca un baiatSe putea realiza mult, mult mai simplu in bash:export lungime_parola=20export nr_parole=1cat /dev/urandom | tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w "$lungime_parola" | head -n "$nr_parole"si vezi ca generatoarele random din bibliotecile implicite ale limbajelor de programare nu au o entropie buna; adica reproduc secvente de biti care pot fi prezise. Quote
Active Members dancezar Posted September 24, 2015 Active Members Report Posted September 24, 2015 password=""if c == 1: password = id1() print passwordif c == 2: password = id2() print passwordif c == 3: password = id3() print passwordif c == 4: password = id4() print passwordToata asta poate fi scrisa mai comprimat asa:functii={1:id1,2:id2,3:id3,4:id4}try: print functii[c]()except KeyError: print "Nu exista alegerea:"+str(c) Quote
bybo Posted September 24, 2015 Author Report Posted September 24, 2015 da mi-am dat si eu seama ca putea fi scrisa mai comprimat dar sunt incepator in python si nu stiu bash sau alte chestii stiu doar putin din python so multumesc pentru explicatii Quote