UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Wiki:Hash    
 
   
jleach
post Jan 18 2012, 07:34 AM
Post#1


UtterAccess Editor
Posts: 9,790
Joined: 7-December 09
From: Staten Island, NY, USA


Topic for wiki article: Hash
Go to the top of the page
 
jleach
post Jan 18 2012, 07:36 AM
Post#2


UtterAccess Editor
Posts: 9,790
Joined: 7-December 09
From: Staten Island, NY, USA


I believe there's a bug with the current implementation of the Hash function. In the picture below, notice that the strings "thisstring" and "thatstring" return the same hash values.
oes anyone know of a fix?
Thanks,
Attached File  hash.gif ( 25.53K )Number of downloads: 15
Go to the top of the page
 
BananaRepublic
post Jan 18 2012, 07:46 AM
Post#3


Dungeon Cleaner
Posts: 1,504
Joined: 16-June 07
From: Banana Republic


without looking into the code too much, I'd bet that this is a case of hash collisions. A good hashing function is supposed to not have collisions but due to the pigeonhole problems that is inevitable.
My workaround? Use an actual hashing function like SHA256.
Here's a VBA implementation of SHA256.
Attached File(s)
Attached File  2199898.zip ( 6.87K )Number of downloads: 3
 
Go to the top of the page
 
jleach
post Jan 18 2012, 07:53 AM
Post#4


UtterAccess Editor
Posts: 9,790
Joined: 7-December 09
From: Staten Island, NY, USA


>> My workaround? Use an actual hashing function like SHA256 <<
unny, that's the exact module I ended up using (though, not cut off by the CodeBox bug)
Go to the top of the page
 
BananaRepublic
post Jan 18 2012, 07:55 AM
Post#5


Dungeon Cleaner
Posts: 1,504
Joined: 16-June 07
From: Banana Republic


Doesn't seems to be cut off? It's a scrollable box?
But yes, there you go. I think it's just one of those time where it's simpler to just use someone's wheel than inventing your own.
Go to the top of the page
 
jleach
post Jan 18 2012, 07:59 AM
Post#6


UtterAccess Editor
Posts: 9,790
Joined: 7-December 09
From: Staten Island, NY, USA


>> Doesn't seems to be cut off? It's a scrollable box? <<
I was (cut off) the first time I looked at it (yes, scrollable, but stopped about 3/4 the way through). A second look shows no though. Oh well.
Do you know if there's a public link to that code? I forget where I downloaded it from (it was a little while ago), but maybe it'd be good to keep the warning in the Hash page on the wiki, along with a link to a more robust procedure?
Go to the top of the page
 
BananaRepublic
post Jan 18 2012, 08:01 AM
Post#7


Dungeon Cleaner
Posts: 1,504
Joined: 16-June 07
From: Banana Republic


Yes, that'll work for me since it's copyrighted but that shouldn't stop us from linking.
Lemme see if i can find .... this probably.
Go to the top of the page
 
datAdrenaline
post Jan 18 2012, 10:18 AM
Post#8


UtterAccess Editor
Posts: 17,929
Joined: 4-December 03
From: Northern Virginia, USA


I originally posted that Hash() function (but ... I robbed the creative genious from different sources ). And yes it has a limitation, I have come across that before and just added an additional Asc() expression in the main function:
CODE
lngTemp = (Asc(Mid$(strHashThis, h - i + 1, 1)) + Asc(Mid$(strHashThis, i, 1))) Xor lngTemp

The second Asc() was added after I ran into the symptom you describe, so ... you could add another variation of the Asc() expression if you want and that would reduce the chances of two strings returning the same value.
The intent of the function was a very basic hash. In the application I originally used it in, we have not had the "duplicate" phenomenon, likely because of the scope in which it is used. By far, the best solution is a more robust function.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    10th December 2017 - 07:11 PM