ail-framework/bin/packages/Hash.py
Starow 1379ef705a Initial import of AIL framework - Analysis Information Leak framework
AIL is a modular framework to analyse potential information leak from unstructured data source like pastes from Past
ebin or similar services. AIL framework is flexible and can be extended to support other functionalities to mine sen
sitive information
2014-08-06 11:43:40 +02:00

32 lines
No EOL
797 B
Python

import hashlib, crcmod, mmh3
class Hash(object):
"""docstring for Hash"""
def __init__(self, name):
self.name = name
def __str__(self):
return "{0}".format(self.name)
def _get_hash_name(self):
return self.name
def _set_hash_name(self, name):
self.p_hash_name = name
def Calculate(self, string):
if self.name == "md5":
hash = hashlib.md5(string).hexdigest()
elif self.name == "sha1":
hash = hashlib.sha1(string).hexdigest()
elif self.name == "crc":
crc32 = crcmod.Crc(0x104c11db7, initCrc=0, xorOut=0xFFFFFFFF)
crc32.update(string)
hash = crc32.hexdigest()
elif self.name == "murmur":
hash = mmh3.hash(string)
return hash