SA-MP Forums Archive
MurmurHash3 for PWN. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MurmurHash3 for PWN. (/showthread.php?tid=359853)



MurmurHash3 for PWN. - CaHbKo - 15.07.2012

I've been looking for a collision-less hash function for non-encryption purposes, and found this one that they claim to be the best.

http://code.******.com/p/smhasher/so...urmurHash3.cpp

The thing is that it is written on C++. I've attempted to convert it, but those 8, 32 byte variables (u_int8/32_t) make me think they can't be simply converted to 'new'. Maybe someone could do it for me? Or even release it in an include.

Thanks in advance.


Re: MurmurHash3 for PWN. - admantis - 15.07.2012

I'm sure if you need to use variables in 16, 8, 4 or 2 bytes you might need to use this include by RyDeR:
https://sampforum.blast.hk/showthread.php?tid=275142


Re: MurmurHash3 for PWN. - CaHbKo - 15.07.2012

As soon as I try to do it again (with rBits) I run into a problem.
Код:
const uint8_t * data = (const uint8_t*)key;
const int nblocks = len / 4;
No idea how to convert a 32 bit string (it's 32 bit afaik lol) into a 8 bit one. I guess 'data' is an array with text and nblocks is the amount of characters, but
Код:
const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
How should I assign array 'blocks' to a value of 'data', which is string, PLUS nblocks*4?

I have no idea what I'm doing with that code tbh
*looks on the door and hopes that ****** or Ryder will come in*


Re: MurmurHash3 for PWN. - Mauzen - 15.07.2012

Main problem will be the long int (64 bits) pawn cant calculate with long values natively. Didnt take a close look at the code, but maybe you can simulate the long ints by connecting 2 pawn cells, but youll need to simulate any kind of used calculations too, which is extremely annoying.
It might be possible to convert it for pawn, but it will be way easier to use it in a plugin, you could basically just take the existing code and register it as a native in any existing plugin.

Converting variabes "downwards" isnt a big problem btw. Just use normal cells, and if it really depends on being just 1/2 bytes long, you could do this:
cell & 0x0000FFFF (2 byte/16 bit value)
cell & 0x000000FF (1 byte/8 bit value)


Re: MurmurHash3 for PWN. - CaHbKo - 15.07.2012

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Main problem will be the long int (64 bits) pawn cant calculate with long values natively. Didnt take a close look at the code, but maybe you can simulate the long ints by connecting 2 pawn cells, but youll need to simulate any kind of used calculations too, which is extremely annoying.
It might be possible to convert it for pawn, but it will be way easier to use it in a plugin, you could basically just take the existing code and register it as a native in any existing plugin.

Converting variabes "downwards" isnt a big problem btw. Just use normal cells, and if it really depends on being just 1/2 bytes long, you could do this:
cell & 0x0000FFFF (2 byte/16 bit value)
cell & 0x000000FF (1 byte/8 bit value)
You've solved my problem with bits, thanks! But what magic is going on there?
Код:
const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
About 64 bits, a bit lower on the page there's MurmurHash3_x86_32, which uses 32 bits!

I guess I'll follow your suggestion and try to make a plugin.


Re: MurmurHash3 for PWN. - CaHbKo - 16.07.2012

I give up... I wasn't even able to complete any of those 2 tutorials by Ryder and Kyosaur. It starts complaining about non-existing header files all the time (while they're in the project!)