Skip to content

Instantly share code, notes, and snippets.

@jaames
Created July 24, 2018 21:02
Show Gist options
  • Select an option

  • Save jaames/96ce8daa11b61b758b6b0227b55f9f78 to your computer and use it in GitHub Desktop.

Select an option

Save jaames/96ce8daa11b61b758b6b0227b55f9f78 to your computer and use it in GitHub Desktop.
Decrypt Mii QR code data from 3DS / Wii U / Miitomo
# Decrypt Mii QR codes from 3DS / Wii U / Miitomo
# Usage: python3 <input file> <output file>
# QR docs: https://www.3dbrew.org/wiki/Mii_Maker
from Crypto.Cipher import AES
from sys import argv
key = bytes([0x59, 0xFC, 0x81, 0x7E, 0x64, 0x46, 0xEA, 0x61, 0x90, 0x34, 0x7B, 0x20, 0xE9, 0xBD, 0xCE, 0x52])
with open(argv[1], "rb") as infile, open(argv[2], "wb") as outfile:
nonce = infile.read(8)
cipher = AES.new(key, AES.MODE_CCM, nonce + bytes([0, 0, 0, 0]))
content = cipher.decrypt(infile.read(0x58))
result = content[:12] + nonce + content[12:]
outfile.write(result)
@KniteRite

Copy link
Copy Markdown

(Likely Error) Crypto.Cipher is outdated, replaced with Cryptodome.Cipher

@jaames

jaames commented Feb 23, 2025

Copy link
Copy Markdown
Author

@KniteRite-Studios Feel free to make a fork :) This gist is 7 years old and unfortunately I'm not interested in maintaining it any more, sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment