Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. __author__ = 'Thomas BOTTON, IGOR ZECEVIC, Daoud MOUSTIR'
  2.  
  3. import random
  4. import hashlib
  5.  
  6. global verifmdp
  7.  
  8. def randommdp():
  9.     i = int(input("Saisir la taille de votre mdp: "))
  10.     mdp = ""
  11.     while i > 0:
  12.         mdp += random.choice('AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn123456789&é^$ù*,;:!?./§/*-+')
  13.         i -= 1
  14.     print("Votre mdp est : ", mdp)
  15.     return mdp
  16.  
  17. def md5(mdp):
  18.     hash_object = hashlib.md5(mdp.encode())
  19.     mdphash = hash_object.hexdigest()
  20.     print("le hash de votre mdp est :",mdphash)
  21.     return mdphash
  22.  
  23. def filehash(mdphash):
  24.     fichier='files\mdp'
  25.     of = open(fichier,'a')
  26.     of.write(mdphash + '\n')
  27.     print("le hash est enregistrer dans le fichier\n\n\n")
  28.     of.close()
  29.  
  30. def verifmdp():
  31.     verifmdp = input("Entrez votre mot de passe : ")
  32.     return verifmdp
  33.  
  34. def verifhash(verifmdphash):
  35.     fichier='files\mdp'
  36.     of=open(fichier,'r')
  37.     i=0
  38.     lignes=of.readlines()
  39.     of.close()
  40.     cpt = 0
  41.     for ligne in lignes:
  42.         #print("verifmdphash = ", verifmdphash)
  43.         #print("ligne = ",ligne)
  44.         if ligne == verifmdphash+'\n':
  45.             cpt += 1
  46.     if cpt > 0:
  47.         print("mot de passe OK")
  48.     else:
  49.         print("mot de passe error")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement