Skip to content

Instantly share code, notes, and snippets.

@akintos
Last active July 3, 2023 15:40
Show Gist options
  • Save akintos/04e2494c62184d2d4384078b0511673b to your computer and use it in GitHub Desktop.
Save akintos/04e2494c62184d2d4384078b0511673b to your computer and use it in GitHub Desktop.
'Yu-Gi-Oh! Master Duel' TextAsset decryption
using System;
using System.IO;
using System.IO.Compression;
static void Main(string[] args)
{
byte[] data = File.ReadAllBytes("CARD_Name");
Xor(data);
using (MemoryStream ms = new MemoryStream(data))
using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress))
using (FileStream fs = File.Create("CARD_Name.dec"))
{
ms.Position = 2;
ds.CopyTo(fs);
}
}
static void Xor(byte[] data)
{
const byte m_iCryptoKey = 0xB3;
for (int i = 0; i < data.Length; i++)
{
byte v = (byte)((i + m_iCryptoKey + 0x23D) * m_iCryptoKey);
v ^= (byte)(i % 7);
data[i] ^= v;
}
}
import zlib
m_iCryptoKey = 0xB3
with open("CARD_Name", "rb") as f:
data = bytearray(f.read())
for i in range(len(data)):
v = i + m_iCryptoKey + 0x23D
v *= m_iCryptoKey
v ^= i % 7
data[i] ^= v & 0xFF
with open("CARD_Name.dec", "wb") as f:
f.write(zlib.decompress(data))
@RndUser0
Copy link

New crypto key for Master Duel v1.4.1: 0x23F

@walk520
Copy link

walk520 commented Feb 10, 2023

New crypto key for Master Duel v1.4.1: 0x23F
Seems to be incorrect.
image

@RndUser0
Copy link

That's odd, the crypto key 0x23F works for me for the files CARD_Desc, CARD_Indx and CARD_Name. Which file are you trying to decrypt?

@walk520
Copy link

walk520 commented Feb 10, 2023

That's odd, the crypto key 0x23F works for me for the files CARD_Desc, CARD_Indx and CARD_Name. Which file are you trying to decrypt?

I've deleted all the files and tried again, and it's working now. Thank you

@drdan2022010
Copy link

hello everyone, Can anyone tell me what is CARD_Genre file, i desc but when i use hex to check i can't read the file. Thanks for your reading
p/s also can anyone tell me how can find the rarity card file? Thanks for your reading

@RndUser0
Copy link

RndUser0 commented May 8, 2023

The crypto key has changed again with the latest update: 0x25F

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