Post: Canonical Hash String [C#/VB.NET/C++]
02-11-2016, 07:55 PM #1
Sonoro
I like anteaters
(adsbygoogle = window.adsbygoogle || []).push({}); This is the method that Black Ops 3 engine uses to hash strings in the game.
The game uses this method to hash data such as dvar names and script function names. :laim:

C#
    internal unsafe static int CanonicalHash(string fname)
{
string x = fname + "\0";
fixed(char* c = x)
{
int hash = (char.ToLower(*c) ^ 0x4B9ACE2F) * 0x1000193;
for (int z = 1; z < x.Length; z++)
hash = (char.ToLower(x[z]) ^ hash) * 0x1000193;
return hash;
}
return 0;
}


VB
    Friend Shared Function CanonicalHash(fname As String) As Integer
Dim x As String = fname & Convert.ToString(vbNullChar)
Dim hash As Integer = (Char.ToLower(c.Target) Xor &H4b9ace2f) * &H1000193
For z As Integer = 1 To x.Length - 1
hash = (Char.ToLower(x(z)) Xor hash) * &H1000193
Next
Return hash

Return 0
End Function


C++
    int CanonicalHash(const char* str)
{
int hash = (tolower(*str) ^ 0x4B9ACE2F) * 0x1000193;
for (size_t i = 1; i <= strlen(str); i++)
hash = (tolower(str[i]) ^ hash) * 0x1000193;
return hash;
}
(adsbygoogle = window.adsbygoogle || []).push({});

The following 5 users say thank you to Sonoro for this useful post:

Sabotage, gοd, OG Trojan041, Rick, VenoxCoding
02-13-2016, 05:49 PM #11
SC58
Former Staff
Originally posted by Bitwise View Post
I don't want credit, I gave it to the owner of the 7s thread for that purpose; the credited source would be 7s, not me. I never stated it wasn't in every cod, why do you have to keep trying to out-do people when all your "research" is nothing but pseudo code from PDB's and PC, lmao.



Indeed, indeed.


I don't want credit, I gave it to the owner of the 7s thread for that purpose; the credited source would be 7s, not me = bit of people knew bout this function before u posted it there.
I never stated it wasn't in every cod = you said within the BO series so menaing only.
why do you have to keep trying to out-do people when all your "research" is nothing but pseudo code from PDB's and PC, lmao. = i just said the name of the function, how is it i'm trying to out do people...

don't come back with a shitty reply, i just stated the name that is all not here to say where research is from etc cause i don't wanna be reply to dumb stuff that started over a word :p
02-13-2016, 09:37 PM #12
Originally posted by SC58 View Post
I don't want credit, I gave it to the owner of the 7s thread for that purpose; the credited source would be 7s, not me = bit of people knew bout this function before u posted it there.
I never stated it wasn't in every cod = you said within the BO series so menaing only.
why do you have to keep trying to out-do people when all your "research" is nothing but pseudo code from PDB's and PC, lmao. = i just said the name of the function, how is it i'm trying to out do people...

don't come back with a shitty reply, i just stated the name that is all not here to say where research is from etc cause i don't wanna be reply to dumb stuff that started over a word :p


"bit of people knew bout this function before u posted it there."

I never said they didn't, that is my exact syntax because I re-wrote how the function worked within the XeX, you wouldn't know because you just copy and pasted the pseudo code, converted it into C# and called it reverse engineering. But for the record, only Shark knew about it originally on here, then he told you and you acted like you knew everything about it and that you reversed anything.

"you said within the BO series so menaing only."

Nice logic you have there, does saying call of duty has guns mean guns only exist on call of duty too?

"i just said the name of the function, how is it i'm trying to out do people..."

Lol, I don't know how saying a specific label only found within a fully labelled PDB is assisting anyone in any way possible. It's completely useless and irrelevant information.
02-14-2016, 05:03 AM #13
SC58
Former Staff
Originally posted by Bitwise View Post
"bit of people knew bout this function before u posted it there."

I never said they didn't, that is my exact syntax because I re-wrote how the function worked within the XeX, you wouldn't know because you just copy and pasted the pseudo code, converted it into C# and called it reverse engineering. But for the record, only Shark knew about it originally on here, then he told you and you acted like you knew everything about it and that you reversed anything.

"you said within the BO series so menaing only."

Nice logic you have there, does saying call of duty has guns mean guns only exist on call of duty too?

"i just said the name of the function, how is it i'm trying to out do people..."

Lol, I don't know how saying a specific label only found within a fully labelled PDB is assisting anyone in any way possible. It's completely useless and irrelevant information.



lol okay then..

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo