get("#356") -- num2hex get("#348") -- rgb functions function roughHashImage(img) local hash = 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) local b = math.floor(bright(rgb(pix))*25+0.5) local p = b local scale = bit32.band(y*w+x, 0xFFFF)+1 local arg = ((p+1)*scale*7) % 1234567 hash = bit32.bxor(hash, arg) --[[if x < 10 then print("scale", scale, "pix", pix, "p", p, "arg", arg, "hash", hash) end]] end --print("y", y, "hash", hash) end return num2hex(hash, 8) end
Began life as a copy of #380
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
2 comment(s) hidden. show
Snippet ID: | #415 |
Snippet name: | Rough-Hash Function |
Eternal ID of this version: | #415/1 |
Text MD5: | 7e158c2267faa430c6f33a04342096ef |
Author: | stefan |
Category: | hash functions |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-02-06 13:46:44 |
Source code size: | 629 bytes / 24 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 969 / 161 |
Referenced in: | [show references] |