import binascii import json import os import struct import base64 from Cryptodome.Cipher import AES from Cryptodome.Util.Padding import unpad from Cryptodome.Util.strxor import strxor as xor from mutagen import mp3, flac, id3 def load_and_decrypt_from_ncm(file_path, target_dir, out_format) -> dict | str: # author: Nzix Repo: nondanee core_key = binascii.a2b_hex('687A4852416D736F356B496E62617857') meta_key = binascii.a2b_hex('2331346C6A6B5F215C5D2630553C2728') f = open(file_path, 'rb') # magic header header = f.read(8) assert binascii.b2a_hex(header) == b'4354454e4644414d' f.seek(2, 1) # key data key_length = f.read(4) key_length = struct.unpack(' 1024 ** 2 * 16 else 'mp3'} f.seek(5, 1) # album cover image_space = f.read(4) image_space = struct.unpack('