get("#356") -- num2hex function RSHash(img) local b, a, hash = 378551, 63689, 0 local w, h = img.width, img.height for y = 0, h-1 do for x = 0, w-1 do local pix = img.getInt(x, y) --hash = (hash * a + pix) % 0x100000000 --a = (a * b) % 0x100000000 hash = bit32.band(hash * a + pix, 0xFFFFFFFF) a = bit32.band(a * b, 0xFFFFFFFF) end end print("rshash: a=", a) return num2hex(hash, 8) end
originally from http://www.partow.net/programming/hashfunctions/ - might have different results
test run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #378 |
Snippet name: | RS Image Hash Function |
Eternal ID of this version: | #378/1 |
Text MD5: | e6a0e122f12fe2317f4e7d8e916e0754 |
Author: | stefan |
Category: | hash functions |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-02-01 21:47:53 |
Source code size: | 461 bytes / 19 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 714 / 163 |
Referenced in: | #379 - Image Hasher (RS) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |