2011-11-20 10:23:31 +01:00
|
|
|
import hashlib
|
|
|
|
from util import hook
|
|
|
|
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2011-11-20 10:23:31 +01:00
|
|
|
@hook.command
|
|
|
|
def md5(inp):
|
2012-02-28 03:03:43 +01:00
|
|
|
".hash <text> -- Returns a md5 hash of <text>."
|
2011-11-20 10:23:31 +01:00
|
|
|
return hashlib.md5(inp).hexdigest()
|
|
|
|
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2011-11-20 10:23:31 +01:00
|
|
|
@hook.command
|
|
|
|
def sha1(inp):
|
2012-02-28 03:03:43 +01:00
|
|
|
".hash <text> -- Returns a sha1 hash of <text>."
|
2011-11-20 10:23:31 +01:00
|
|
|
return hashlib.sha1(inp).hexdigest()
|
2012-02-02 14:05:11 +01:00
|
|
|
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2011-11-20 10:23:31 +01:00
|
|
|
@hook.command
|
|
|
|
def sha256(inp):
|
2012-02-28 03:03:43 +01:00
|
|
|
".hash <text> -- Returns a sha256 hash of <text>."
|
2011-11-20 10:23:31 +01:00
|
|
|
return hashlib.sha256(inp).hexdigest()
|
2012-02-02 14:05:11 +01:00
|
|
|
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2011-11-20 10:23:31 +01:00
|
|
|
@hook.command
|
|
|
|
def sha512(inp):
|
2012-02-28 03:03:43 +01:00
|
|
|
".hash <text> -- Returns a sha512 hash of <text>."
|
2011-11-20 10:23:31 +01:00
|
|
|
return hashlib.sha512(inp).hexdigest()
|
|
|
|
|
2012-04-02 18:17:55 +02:00
|
|
|
|
2011-11-20 10:23:31 +01:00
|
|
|
@hook.command
|
|
|
|
def hash(inp):
|
2012-02-28 03:03:43 +01:00
|
|
|
".hash <text> -- Returns hashes of <text>."
|
2011-11-20 10:23:31 +01:00
|
|
|
return ', '.join(x + ": " + getattr(hashlib, x)(inp).hexdigest()
|
2012-05-10 21:40:27 +02:00
|
|
|
for x in ['md5', 'sha1', 'sha256'])
|