2016-04-20 12:52:23 +00:00
|
|
|
import hashlib
|
|
|
|
|
|
|
|
class Module(object):
|
2018-09-02 18:54:45 +00:00
|
|
|
def __init__(self, bot, events, exports):
|
2016-04-20 12:52:23 +00:00
|
|
|
self.bot = bot
|
2018-09-19 12:25:12 +00:00
|
|
|
events.on("received.command.hash").hook(self.hash, min_args=2,
|
|
|
|
help="Hash a string", usage="<algo> <string>")
|
2016-04-20 12:52:23 +00:00
|
|
|
|
|
|
|
def hash(self, event):
|
|
|
|
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")
|