Created
July 28, 2020 14:52
-
-
Save reo-ar/ca89cc4bb37669891c8e346827b4b5f0 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 os | |
async def curse_hasher(mod): | |
with open(mod, "rb") as mod_file: | |
file_bytes = mod_file.read() | |
blocklist = (0x9, 0xA, 0xD, 0x20) | |
length = sum(byte not in blocklist for byte in file_bytes) | |
seed = 1 | |
h = seed ^ length | |
k = 0x0 | |
m = 0x5BD1E995 | |
r = 24 | |
shift = 0x0 | |
for byte in file_bytes: | |
if byte in blocklist: | |
continue | |
k |= byte << shift | |
shift += 0x8 | |
if shift == 0x20: | |
k = (k * m) & 0xFFFFFFFF | |
k ^= k >> r | |
k = (k * m) & 0xFFFFFFFF | |
h = (h * m) & 0xFFFFFFFF | |
h ^= k | |
k = 0x0 | |
shift = 0x0 | |
if shift > 0: | |
h ^= k | |
h = (h * m) & 0xFFFFFFFF | |
h ^= h >> 13 | |
h = (h * m) & 0xFFFFFFFF | |
h ^= h >> 15 | |
print(np.uint32(h)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment