Skip to content

Instantly share code, notes, and snippets.

@neckothy
Created September 17, 2023 09:35
Show Gist options
  • Save neckothy/5c8e2f9bb10876c83a9e090491071909 to your computer and use it in GitHub Desktop.
Save neckothy/5c8e2f9bb10876c83a9e090491071909 to your computer and use it in GitHub Desktop.
get valid x-mgpk-hash headers for requests to a certain terrible manga platform nobody should be supporting
# original PoC from sometime in May, should still work
# valid for both APIs (JP/US)
import hashlib
# returned on register, login, etc
HASH_KEY = ""
# my PoC, cleaned up by someone much smarter than me (ty boss)
def get_mgpk_hash(params):
sha_256 = hashlib.sha256()
for k, v in sorted({"hash_key": HASH_KEY, **params}.items()):
sha_256.update(bytes(hashlib.md5(bytes(v, "utf-8")).hexdigest(), "utf-8"))
return sha_256.hexdigest()
params = { ... }
headers = { ... }
headers["x-mgpk-hash"] = get_mgpk_hash(params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment