Skip to content

Instantly share code, notes, and snippets.

@WitherOrNot
Created January 18, 2022 23:12
Show Gist options
  • Save WitherOrNot/5c5716b201f042e176cb18281a7ff86a to your computer and use it in GitHub Desktop.
Save WitherOrNot/5c5716b201f042e176cb18281a7ff86a to your computer and use it in GitHub Desktop.
Generate titlekeys for WiiU games
from hashlib import pbkdf2_hmac
from binascii import hexlify, unhexlify
from Crypto.Hash import MD5
import sys
SECRET = b'\xfd\x04\x01\x05\x06\x0b\x11\x1c-I'
def hexify(s):
return hexlify(s).decode("utf-8")
def md5(s):
md = MD5.new()
md.update(s)
return md.digest()
def gen_key(titleid, pasw):
titleid = unhexlify(titleid)[1:]
salt = md5(SECRET + titleid)
return pbkdf2_hmac('sha1', pasw.encode("utf-8"), salt, 20, 16)
if __name__ == "__main__":
if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} <titleid> (password)")
if len(sys.argv) >= 3:
pasw = sys.argv[2]
else:
pasw = "mypass"
print(f"Decrypted titlekey: {hexify(gen_key(sys.argv[1], pasw))}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment