#!/usr/bin/python3.4 # -*- coding: utf-8 -*- # Copyright © 2015 Matthieu DUVAL, Rudy DUCHE # This file is part of RizzleHash. # RizzleHash is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # RizzleHash is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with RizzleHash. If not, see 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() else: print(" Error : " + typeCryptage + " hash methode not suported") print(" We support : md5, sha1, sha224, sha256, sha384, sha512") print() sys.exit() self.passwordCrypte = passwordCrypte return self.passwordCrypte #si le fichier est lancé seul if __name__ == '__main__' : app = CryptPass() print() print(app.getHash(sys.argv[1],sys.argv[2])) print() sys.exit()