I created and implemented the save / load mechanic. It works as a 1-way hash. There are 10 code points you have to enter, which are the numbers 1, 2, 3 and 4 on the map. Normal triggers are used to detect which symbol the defiler has cast the dark swarm on.
The 4 different values have got large integer numbers associated with them: 1 = 954437177, 2 = 1908874353, 3 = 2863311530, 4 = 3817748708. A passcode consists of 10 values between 1 and 4, eg a code might be 1113323242, so there are 1,048,576 possible unique codes.
Each index in the passcode has the xth lowest prime number associated with it, so:
index 1 = 2
i2 = 3
i3 = 5
i4 = 7
i5 = 11
i6 = 13
i7 = 17
i8 = 19
i9 = 23
i10 = 29
The formula to calculate the final hash value is cumulative and takes the previous steps result, adds the current code value and then multiplies it by the index, so using 1113323242 as the code:
(0 + 954437177) * 2 = 1908874354
(1908874354 + 954437177) * 3 = 8589934593
(8589934593 + 954437177) * 5 = 47721858850
(47721858850 + 2863311530) * 7 = 354096192660
(354096192660 + 2863311530) * 11 = 3926554546090
(3926554546090 + 1908874353) * 13 = 51070024465759
(51070024465759 + 2863311530) * 17 = 868239092213913
(868239092213913 + 1908874353) * 19 = 16496579020677054
(16496579020677054 + 3817748708) * 23 = 379421405283792526
(379421405283792526 + 1908874353) * 29 = 11003220808587339491
Triggers are implemented to calculate all of the above as the player enters their passcode, so in sharing the above I haven't given away anything that you couldn't find out from reading the triggers in the map. Because SC only handles 32 bit numbers, each value greater than 2^32 is (automatically) MODed by 2^32, so the final value is 11003220808587339491 MOD 2^32 = 554,231,523 . Then we have a trigger that says "if hashinput is exactly 554231523, set player level to 40, class/EXP/minerals to whatever". Obviously if there are 12 character classes and 100 levels, then there are 1200 of these triggers, 1 for each level and character class.
If you were to unprotect the map and look at the triggers, you can work out the above calculation algorithm, but the map itself does NOT store the original input codes. All you know is the algorithm used to calculate the hash and the final hash values for the 1200 different triggers. But because it's a 1-way hash, it's impossible to look at the value 554,231,523 and work backwards to determine what the original passcode is, because the 32-bit integer wrap around (automatic MOD operation) discards data at every step, while retaining enough data to make the final value unique.
For a given final hash code, the only way to work out the passcode is to brute-force all possible 1,048,576 passcodes, to see which one results in that hash (or, in the specific case of 554231523, read this post).
Post has been edited 2 time(s), last time on May 19 2018, 11:47 pm by Lanthanide.
None.