Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #378 // RS Image Hash Function

Lua code

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

Author comment

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: 713 / 162
Referenced in: [show references]