Created
May 26, 2019 16:29
-
-
Save jackyyf/32f666ed972cdd377a6f8dd3c31acc18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys; reload(sys); sys.setdefaultencoding('utf-8'); del sys.setdefaultencoding | |
from pyblake2 import blake2s | |
GLOBAL_LUCKY = 'j3xyAxdP4vXAecJy' | |
PENALTY_BASE = 1 << 252 | |
results = [] | |
with open('forms.txt') as f: | |
for line in f.readlines(): | |
if not line: | |
continue | |
_, _, uname, luckystring, penalty = line.split('\t') | |
print >>sys.stderr, '-' * 64 | |
print >>sys.stderr, 'User:', uname | |
penalty = int(penalty) | |
hash1 = '0x' + blake2s(luckystring + GLOBAL_LUCKY + uname).hexdigest() | |
print >>sys.stderr, 'Hash:', hash1 | |
hash2 = int(hash1, 16) + PENALTY_BASE * penalty | |
print >>sys.stderr, 'Hash with penalty:', hex(hash2) | |
print >>sys.stderr | |
results.append((uname, penalty, hash2)) | |
results.sort(cmp=lambda x, y : 1 if x[2] > y[2] else 0 if x[2] == y[2] else -1) | |
for result in results: | |
print '%16s 0x%65x (Penalty = %d)' % (result[0], result[2], result[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment