-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhasher.py
33 lines (31 loc) · 1.12 KB
/
hasher.py
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
import hashlib
from tqdm import tqdm
def secure_hash(text, bar=False):
if bar:
pbar = tqdm(total=10000, bar_format=' |{bar}| ', colour='CYAN')
alphabet = 'm!n@b#v$c^x&z(l]k)j[h}g{f\d"s;a>p<o/i;u>y<t:r+e=w_q'
salt = ""
changed_salt = alphabet[len(text) % 26]
for letter in text:
if letter in alphabet:
salt += alphabet[(alphabet.index(letter) + len(text)) % 26]
salt = salt[::-1]
for i in range(100000):
text = hashlib.sha512(str(text + salt).encode("utf-8")).hexdigest()
if i % 10 == 0:
if bar:
pbar.update(n=1)
try:
index = int(text[0])
except ValueError:
try:
index = alphabet.index(changed_salt[0])
except IndexError:
index = 2
changed_salt = ""
for letter in salt:
if letter in alphabet:
changed_salt += alphabet[(alphabet.index(letter) +
len(text)*index) % 26]
salt = changed_salt
return text