18 lines
696 B
Python
18 lines
696 B
Python
import hashlib
|
|
from src import ModuleManager, Utils
|
|
|
|
class Module(ModuleManager.BaseModule):
|
|
@Utils.hook("received.command.hash", min_args=2)
|
|
def hash(self, event):
|
|
"""
|
|
:help: Hash a given string with a given algorithm
|
|
:usage: <algo> <string>
|
|
"""
|
|
algorithm = event["args_split"][0].lower()
|
|
if algorithm in hashlib.algorithms_available:
|
|
phrase = " ".join(event["args_split"][1:])
|
|
cipher_text = hashlib.new(algorithm, phrase.encode("utf8")
|
|
).hexdigest()
|
|
event["stdout"].write("%s -> %s" % (phrase, cipher_text))
|
|
else:
|
|
event["stderr"].write("Unknown algorithm provided")
|