Assetto Corsa car modifier.
Release 0.1 is available in the release section of this repository.
Below is an explanation on how the CreateKey & Decryption functions work. Assetto utilises a simple ROT algorithim for the encryption/decryption.
(byte)((value % 256 + 256) % 256);
Assetto uses the folder name of the car to create an encryption/decryption key. Once the .acd is packed with the key, if the folder name is changed it will no longer be decryptable. In the example below the folder name we are using is:
The key is structured as follows:
000-000-000-000-000-000-000-000
Each octet is concatenated with a "-" delimiter.
folderName = folderName.ToLower();
int aggregateSeed = folderName.Aggregate(0, (int current, char t) =>
{
return current + t;
});
Firstly the folderName is converted to lower case and its characters represented as its unicode counterpart are summed together, this gives:
The process of aggregation is shown below.
Current: 0, T: k, T(NUM): 107
Current: 107, T: s, T(NUM): 115
Current: 222, T: _, T(NUM): 95
Current: 317, T: a, T(NUM): 97
Current: 414, T: u, T(NUM): 117
Current: 531, T: d, T(NUM): 100
Current: 631, T: i, T(NUM): 105
Current: 736, T: _, T(NUM): 95
Current: 831, T: s, T(NUM): 115
Current: 946, T: p, T(NUM): 112
Current: 1058, T: o, T(NUM): 111
Current: 1169, T: r, T(NUM): 114
Current: 1283, T: t, T(NUM): 116
Current: 1399, T: _, T(NUM): 95
Current: 1494, T: q, T(NUM): 113
Current: 1607, T: u, T(NUM): 117
Current: 1724, T: a, T(NUM): 97
Current: 1821, T: t, T(NUM): 116
Current: 1937, T: t, T(NUM): 116
Current: 2053, T: r, T(NUM): 114
Current: 2167, T: o, T(NUM): 111
The result of 2278 is then converted to a single byte represention using the helper function intToByte shown above which yields:
This is the first octet of the key.
a = folderName Length
b = folderName Array
For convenience the rest of the calculations will be represented as a math/programming expression. Treat summation as a simple loop.
temp = 0
temp = 0
temp = 5763
temp = 66
temp = 101
temp = 171
temp = 171
All octets are ran through the IntToByte function and their product is concatenated using a "-" delimiter as seen below.
key = string.Join("-", new object[]
{
octet1,
octet2,
octet3,
octet4,
octet5,
octet6,
octet7,
octet8
});
I understand the above probably looks like gibberish and it's most likely easier to just read the code, however I thought I might aswell include it anyways.
The decrypt & encrypt functions both make use of the key created above to decrypt the values within the ACD file.