PocketRelay/Server

Calculate Game Protocol Version Hash

Closed this issue · 1 comments

const GAME_PROTOCOL_VERSION_HASH: u64 = 0x5a4f2b378b715c6;

In my own blaze emulator i am using this to calculate the game protocol version hash, here you can see it in C#. It appears to be FNV1 hash but in a bit different way. When i tested this against EA generated hashes, they were matching.

I am not familiar with Rust at all, so it is better i let it up to you to implement it :D

        public static ulong GetGameProtocolVersionHash(string protocolVersion)
        {
            protocolVersion ??= string.Empty;
            //FNV1 HASH - the same hashing logic is used in ea blaze for game protocol versions
            byte[] buf = Encoding.UTF8.GetBytes(protocolVersion);
            ulong hash = 2166136261UL;
            foreach (byte c in buf)
                hash = (hash * 16777619) ^ c;
            return hash;
        }

Thanks, implemented in 398410d