-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathHasher.py
More file actions
70 lines (64 loc) · 2.49 KB
/
Hasher.py
File metadata and controls
70 lines (64 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from .. import loader, utils
from hashlib import md5, sha1, sha224, sha256, sha384, sha512, blake2b, blake2s
def register(cb):
cb(HasherMod())
class HasherMod(loader.Module):
"""Hashing text and files"""
strings = {'name': 'Hasher'}
def __init__(self):
self.name = self.strings['name']
self._me = None
self._ratelimit = []
async def client_ready(self, client, db):
self._db = db
self._client = client
self.me = await client.get_me()
async def md5cmd(self, message):
""".md5 <(text or media) or (reply to text or media)>\nHashing to md5"""
await hashing(message, 0)
async def sha1cmd(self, message):
""".sha1 <(text or media) or (reply to text or media)\nHashing to sha1"""
await hashing(message, 1)
async def sha224cmd(self, message):
""".sha224 <(text or media) or (reply to text or media)\nHashing to sha224"""
await hashing(message, 2)
async def sha256cmd(self, message):
""".sha255 <(text or media) or (reply to text or media)\nHashing to sha256"""
await hashing(message, 3)
async def sha384cmd(self, message):
""".sha384 <(text or media) or (reply to text or media)\nHashing to sha384"""
await hashing(message, 4)
async def sha512cmd(self, message):
""".sha512 <(text or media) or (reply to text or media)\nHashing to sha512"""
await hashing(message, 5)
async def blake2bcmd(self, message):
""".blake2 <(text or media) or (reply to text or media)\nHashing to blake2"""
await hashing(message, 6)
async def blake2scmd(self, message):
""".blake2s <(text or media) or (reply to text or media)\nHashing to blake2s"""
await hashing(message, 7)
async def hashing(m, type):
types = [md5, sha1, sha224, sha256, sha384, sha512, blake2b, blake2s]
typez = ["md5", "sha1", "sha224", "sha256", "sha384", "sha512", "blake2b", "blake2s"]
reply = await m.get_reply_message()
mtext = utils.get_args_raw(m)
if m.media:
await m.edit("<b>D o w n l o a d i n g . . .</b>")
data = await m.client.download_file(m, bytes)
elif mtext:
data = mtext.encode()
elif reply:
if reply.media:
await m.edit("<b>D o w n l o a d i n g . . .</b>")
data = await m.client.download_file(reply, bytes)
else:
data = reply.raw_text.encode()
else:
await m.edit(f"<b>What hashing to {typez[type]}?</b>")
return
await m.edit("<b>H a s h i n g . . .</b>")
try:
result = types[type](data)
await m.edit(typez[type].upper()+": <code>" + str(result.hexdigest()).upper()+"</code>")
except:
await m.edit("<b>ERЯOR!</b>")