From Mania Tech Wiki
Jump to: navigation, search

.cry files are weakly encrypted text files used in Virtual Skipper and early versions of TrackMania. For example, the VskBoatImporter of Virtual Skipper creates an Info.cry from the Info.txt with the basic information about the boat (name, website, author) and adds it to the boat zip file. As a cipher, XOR encryption is used with a rotating key. After encryption, the ciphertext is compressed by LZO.

File structure

uint32 uncompressedSize
uint32 compressedSize

Restore the plaintext

After the data block is decompressed, the text string can be decrypted by applying the bitwise XOR operator to each character with the given key. The default key is rotated bitwise to the left, depending on the length of the text. The new key is then extended to the text length by repeating it:

uint64 key = 0xCF08317C90460052;
uint32 shift = uncompressedSize & 0x3F;
uint64 rotkey = (key << shift) | (key >> (64 - shift));
for (int i = 0; i < uncompressedSize; i++)
    uncompressedData[i] ^= *( (byte*)&rotkey + (i & 0x7) );