mirror of
https://github.com/OALabs/hashdb
synced 2026-06-08 12:05:11 +00:00
dd1b7457c1
simplified algorithm structure added tests readied files for linting
20 lines
470 B
Python
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)
|