Jump to content
bybo

Password Generator

Recommended Posts

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 string
import random
def 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 Puka
Here u can select how many caracters your password gonna have ex: 5 Char.=1xgf5
--------------------------------------------------------------------------------
1.Password with 3 characters
2.Password with 5 characters
3.Password with 8 characters
4.Password with 12 characters
"""
c = input ("Type your option(1/2/3/4): ")
password = ""
if c == 1:
password = id1()
print password
if c == 2:
password = id2()
print password
if c == 3:
password = id3()
print password
if c == 4:
password = id4()
print password

m = raw_input("Do you wish to save the password?(y/n)")
print m
if 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 by bybo
Link to comment
Share on other sites

  • Active Members

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 :D

PS: In python 3.x raw_input() devine input() iar input()-ul din 2.x a fost removed.

Edited by MrGrj
Link to comment
Share on other sites

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 string
import random
def 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 Puka
Here u can select how many caracters your password gonna have ex: 5 Char.=1xgf5
--------------------------------------------------------------------------------
1.Password with 3 characters
2.Password with 5 characters
3.Password with 8 characters
4.Password with 12 characters
"""
c = input ("Type your option(1/2/3/4): ")
password = ""
if c == 1:
password = id1()
print password
if c == 2:
password = id2()
print password
if c == 3:
password = id3()
print password
if c == 4:
password = id4()
print password

m = 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 baiat

Se putea realiza mult, mult mai simplu in bash:


export lungime_parola=20
export nr_parole=1
cat /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.

Link to comment
Share on other sites

  • Active Members


password=""
if c == 1:
password = id1()
print password
if c == 2:
password = id2()
print password
if c == 3:
password = id3()
print password
if c == 4:
password = id4()
print password

Toata 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)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...