Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Thomas BOTTON, IGOR ZECEVIC, Daoud MOUSTIR'
- import random
- import hashlib
- global verifmdp
- def randommdp():
- i = int(input("Saisir la taille de votre mdp: "))
- mdp = ""
- while i > 0:
- mdp += random.choice('AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn123456789&é^$ù*,;:!?./§/*-+')
- i -= 1
- print("Votre mdp est : ", mdp)
- return mdp
- def md5(mdp):
- hash_object = hashlib.md5(mdp.encode())
- mdphash = hash_object.hexdigest()
- print("le hash de votre mdp est :",mdphash)
- return mdphash
- def filehash(mdphash):
- fichier='files\mdp'
- of = open(fichier,'a')
- of.write(mdphash + '\n')
- print("le hash est enregistrer dans le fichier\n\n\n")
- of.close()
- def verifmdp():
- verifmdp = input("Entrez votre mot de passe : ")
- return verifmdp
- def verifhash(verifmdphash):
- fichier='files\mdp'
- of=open(fichier,'r')
- i=0
- lignes=of.readlines()
- of.close()
- cpt = 0
- for ligne in lignes:
- #print("verifmdphash = ", verifmdphash)
- #print("ligne = ",ligne)
- if ligne == verifmdphash+'\n':
- cpt += 1
- if cpt > 0:
- print("mot de passe OK")
- else:
- print("mot de passe error")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement