-1

I am looking for Delphi code to use Murmur2 to hash a file stream. Should support both 32-bit and 64-bit.

Daniel
  • 315
  • 5
  • 16

1 Answers1

1

There's an implementation in another question about hashing. It certainly supports 32-bit code. I can't comment on how readily it transfers to 64 bits.

Community
  • 1
  • 1
Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • That code has exact same meaning under 64 bit compiler – David Heffernan Dec 26 '12 at 08:11
  • Thank you, I saw that but that is for a string. I don't know how to translate that into hashing a stream. – Daniel Dec 26 '12 at 12:02
  • @Daniel Try this: http://pastebin.com/68KEDDp4 It's also worth pointing out that `AnsiString` isn't the best data type for a hash algo. I'd say that `TBytes` would be better. Easy to adapt algo to that. – David Heffernan Dec 26 '12 at 12:38
  • @DavidHeffernan: I get "integer overlow" trying to use this function on a stream. I experimented with changing longword to int64 with the same error. – Daniel Dec 26 '12 at 14:53
  • Don't do that! Very bad idea! Don't change the code at all. Just disable integer overflow checking for that code. Put the has code in a separate unit and add this right at the top of that unit: `{$OVERFLOWCHECKS OFF}` – David Heffernan Dec 26 '12 at 14:55
  • @Daniel Use the unit in this pastebin and you are good to go: http://pastebin.com/Bw5Sfih0 – David Heffernan Dec 26 '12 at 15:00
  • @DavidHeffernan, that works great, thank you! Please post that as an official answer so I can accept it. – Daniel Dec 26 '12 at 15:54
  • Please accept Rob's answer. If you want to include my pastebin code as an answer of your own please do. But Rob's is the answer that you should accept. – David Heffernan Dec 26 '12 at 15:58