diff --git a/geki/calc_title_server_enc_key.py b/geki/calc_title_server_enc_key.py index e5fc768..c1e2cee 100644 --- a/geki/calc_title_server_enc_key.py +++ b/geki/calc_title_server_enc_key.py @@ -34,12 +34,27 @@ ASCII_EX_CHARACTERS = ( ) +def to_ascii(input: bytes): + output: list[int] = [] + + for b in input: + while b >= 122: + b -= 122 + + while b < 48: + b += 48 + + output.append(b) + + return bytes(output) + + def to_ascii_ex(input: bytes): output: list[int] = [] for b in input: b = (b - 48) % len(ASCII_EX_CHARACTERS) - output.append(b) + output.append(ord(ASCII_EX_CHARACTERS[b])) return bytes(output) @@ -69,12 +84,15 @@ with (cast(Path, args.mu3_data_path) / "resources.assets").open("rb") as f: key=args.key_iv_digest_fixed ).digest() + if data.m_Name in {"noise0", "noise1"}: + key = to_ascii(key) + + if args.ascii_ex: + key = to_ascii_ex(key) + if data.m_Name == "noise1": key = key[:16] elif data.m_Name == "noise2": key = key[:8] - if args.ascii_ex and data.m_Name in {"noise0", "noise1"}: - key = to_ascii_ex(key) - print(f"{FILE_MAP[data.m_Name]}: {key.hex()}")