You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
8 years ago
|
# -*- coding: utf-8 -*-
|
||
|
import hashlib
|
||
|
import random
|
||
|
|
||
|
from BF_Constants import *
|
||
|
|
||
|
tabChar = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||
|
|
||
|
class Encryption():
|
||
|
def __init__(self):
|
||
|
self.passwordNonCrypte = ""
|
||
|
self.key = ""
|
||
|
self.typeCryptage = ""
|
||
|
self.passwordCrypte = ""
|
||
|
return None
|
||
|
|
||
|
def getRandKey(self, keySize):
|
||
|
keyRand = ""
|
||
|
i = 0
|
||
|
while i < keySize:
|
||
|
keyRand = keyRand + round(randrange(0, len(tabChar)),0)
|
||
|
return keyRand
|
||
|
|
||
|
def md5(self, string):
|
||
|
return hashlib.md5(string.encode('utf-8')).hexdigest()
|
||
|
|
||
|
def sha1(self, string):
|
||
|
return hashlib.sha1(string.encode('utf-8')).hexdigest()
|
||
|
|
||
|
def sha224(self, string):
|
||
|
return hashlib.sha224(string.encode('utf-8')).hexdigest()
|
||
|
|
||
|
def sha384(self, string):
|
||
|
return hashlib.sha384(string.encode('utf-8')).hexdigest()
|
||
|
|
||
|
def sha256(self, string):
|
||
|
return hashlib.sha256(string.encode('utf-8')).hexdigest()
|
||
|
|
||
|
def sha512(self, string):
|
||
|
return hashlib.sha512(string.encode('utf-8')).hexdigest()
|
||
|
|
||
|
def none(self, string):
|
||
|
return string
|
||
|
|
||
|
def hashForLambda(self, functionLambda, string):
|
||
|
return functionLambda(string)
|
||
|
|
||
|
|
||
|
#si le fichier est lancé seul
|
||
|
if __name__ == '__main__' :
|
||
|
sys.exit()
|