Zhaxxy / SCurseDecPS4

Simple command line tool to decompress and recompress savegame for Shantae and the Pirate's Curse, along side generating the correct hash
0 stars 0 forks source link

hashing algo #1

Open bucanero opened 10 months ago

bucanero commented 10 months ago

https://github.com/Zhaxxy/SCurseDecPS4/blob/c909a58cd7be3cded32e6dac9acd74e11cb984e5/SCurseDecPS4.py#L11

Regarding the algo, it's indeed the standard lookup2 algo by Bob Jenkins, as used on Linux and other systems. You can find the standard linux implementation in C here: https://kernel.googlesource.com/pub/scm/linux/kernel/git/klassert/ipsec/+/refs/tags/v2.6.19-rc3/include/linux/jhash.h

I have tested it and compared results with your Python code and both match.

The only "customization" from the game is adding the magic value 0x4900DC7C to the jhash() result

bucanero commented 10 months ago

btw, this is a valid python version: https://stackoverflow.com/a/3611698

bucanero commented 9 months ago

Btw, I was comparing Shantae Pirate Curse saves from Steam (PC), like these saves: https://www.speedrun.com/satpc/resources/ux414

and I can confirm tha they're using the same structure, 4 bytes checksum, then the zipped data. The only difference is the "magic value" added to the Jenkins hash: 0x20D4ACC1

So I guess your tool can also support PC saves, as long as it has an option so you can re-calculate hash with the PC magic value or the PS4 magic value.