-3

I see this code in a web game SHA512(SeedServer + "|" + SeedUser) and I'm trying to reproduce this hash. I tried in PHP:

<?php
echo hash('SHA512',
  '0f13f859096d0cf5029711628c18e22792198a60eb0e561225b03a7316e813ce'+'|'+
  '4379f8c6822d73c6340bc9a5f9b6380fc2e90d685f5a7e5616779638a2571fa3');
?> 

but I can't get the same hash that is in the game.

For example I use:

seedserver:0f13f859096d0cf5029711628c18e22792198a60eb0e561225b03a7316e813ce
seeduser  :4379f8c6822d73c6340bc9a5f9b6380fc2e90d685f5a7e5616779638a2571fa3

In the game, the result is :

488363e8bc97ca413ff4b0eac65c4bba05d2ade01d64d5e7d173a914257921024efb57dd5ece9dfced3a46767b6f0e830d5e98d59dd1ddb175076e2de9bf4bdd

How can I reproduce this result in PHP?

1 Answer 1

7

SHA 512 is not simply two SHA 256 hashes summed together. Ok now that that is out of the way here goes some tests. The SHA512 of the string

0f13f859096d0cf5029711628c18e22792198a60eb0e561225b03a7316e813ce|4379f8c6822d73c6340bc9a5f9b6380fc2e90d685f5a7e5616779638a2571fa3

is

488363e8bc97ca413ff4b0eac65c4bba05d2ade01d64d5e7d173a914257921024efb57dd5ece9dfced3a46767b6f0e830d5e98d59dd1ddb175076e2de9bf4bdd

Which matches the result from the game.

The problem is that the PHP string appending method is . not + so this should get the answer.

<?php
echo hash('SHA512','0f13f859096d0cf5029711628c18e22792198a60eb0e561225b03a7316e813ce'.'|'.'4379f8c6822d73c6340bc9a5f9b6380fc2e90d685f5a7e5616779638a2571fa3');
?> 
2
  • Note. I just did a quick edit because I dropped a ' from my PHP. Now the code should work. I tested it at sandbox.onlinephpfunctions.com.
    – AstroDan
    Mar 25, 2016 at 16:19
  • 1
    If this solves your problem you can accept this answer by clicking the check box next to it.
    – AstroDan
    Mar 25, 2016 at 17:35

Not the answer you're looking for? Browse other questions tagged .