Skip to content

Instantly share code, notes, and snippets.

@dogtopus
Last active April 6, 2023 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogtopus/4c5f2d4da4567b6204435ca335e63e0a to your computer and use it in GitHub Desktop.
Save dogtopus/4c5f2d4da4567b6204435ca335e63e0a to your computer and use it in GitHub Desktop.
Kagiya? What's that
import hashlib
def secret(start: int, size: int) -> bytes:
result = bytearray()
add = start + size
for i in range(size):
result.append(start & 0xff)
next = start + add
add = start
start = next
return bytes(result)
SECRET = secret(-3, 10)
def derive(tid: bytes, passphrase: bytes) -> bytes:
tids = hashlib.md5(SECRET + tid.lstrip(b'\x00')).digest()
return hashlib.pbkdf2_hmac('sha1', passphrase, tids, 20, 32)
if __name__ == '__main__':
print(derive(bytes.fromhex('000100014e414150'), b'nintendo').hex())
print(derive(bytes.fromhex('000100014e414150'), b'mypass').hex())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment