# -*- coding: utf-8 -*- import hashlib import random import sys tabChar = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") class CryptPass(): def __init__(self): self.passwordNonCrypte = "" self.key = "" self.typeCryptage = "" self.passwordCrypte = "" return None def getHash(self, passwordNonCrypteWithKey, typeCryptage): self.passwordCrypte = "" passwordNonCrypteWithKey = passwordNonCrypteWithKey.encode() if typeCryptage == "md5": passwordCrypte = hashlib.md5(passwordNonCrypteWithKey).hexdigest() elif typeCryptage == "sha1": passwordCrypte = hashlib.sha1(passwordNonCrypteWithKey).hexdigest() elif typeCryptage == "sha224": passwordCrypte = hashlib.sha224(passwordNonCrypteWithKey).hexdigest() elif typeCryptage == "sha256": passwordCrypte = hashlib.sha256(passwordNonCrypteWithKey).hexdigest() elif typeCryptage == "sha384": passwordCrypte = hashlib.sha384(passwordNonCrypteWithKey).hexdigest() elif typeCryptage == "sha512": passwordCrypte = hashlib.sha512(passwordNonCrypteWithKey).hexdigest() self.passwordCrypte = passwordCrypte return self.passwordCrypte #si le fichier est lancé seul if __name__ == '__main__' : app = CryptPass() print(app.getHash(sys.argv[1],"md5")) sys.exit()