Files
herrcore dd1b7457c1 added test and cleaned code
simplified algorithm structure
added tests
readied files for linting
2021-08-17 18:26:25 -04:00

20 lines
470 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Malware hash library.
"""
import algorithms
class AlgorithmError(Exception):
pass
def list_algorithms():
return list(algorithms.modules.keys())
def hash(algorithm_name, data):
if algorithm_name not in list(algorithms.modules.keys()):
raise AlgorithmError("Algorithm not found")
if type(data) == str:
data = data.encode('utf-8')
return algorithms.modules[algorithm_name].hash(data)