added hash.py. why not.
This commit is contained in:
parent
c7c5e800fe
commit
c5c53bc481
1 changed files with 18 additions and 0 deletions
18
modules/hash.py
Normal file
18
modules/hash.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import hashlib
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
bot.events.on("received").on("command").on("hash"
|
||||
).hook(self.hash, min_args=2, help="Hash a string",
|
||||
usage="<algo> <string>")
|
||||
|
||||
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")
|
Loading…
Reference in a new issue