473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Hash value

4
Hi,

I want to generate a hash key from a string, and I want to the hash key is the same value for the same string. But it turns out all the hash functions I have tried, generate different keys from the same string. For example, if I run an excusable hash function several times in following example, it gave me all different values even the string does not change:

$ BobJenkinHash "hello"
0x183B3443

$ BobJenkinHash "hello"
0x24082445

Is it possible to generate the same hash value based on the same string?

Thank you.

Jim
Aug 27 '07 #1
4 2515
gpraghuram
1,275 Expert 1GB
Hi,

I want to generate a hash key from a string, and I want to the hash key is the same value for the same string. But it turns out all the hash functions I have tried, generate different keys from the same string. For example, if I run an excusable hash function several times in following example, it gave me all different values even the string does not change:

$ BobJenkinHash "hello"
0x183B3443

$ BobJenkinHash "hello"
0x24082445

Is it possible to generate the same hash value based on the same string?

Thank you.

Jim
Have u heard about CRC, if yes then that can help u.
Try to use 32-bit crc(the code for this is available in net).
This will generate a unsigned long nu,ber for every input string u give.

Raghuram
Aug 27 '07 #2
jimhce
4
Could you point me the URL?

Thank you.

Jim
Aug 27 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
Also, if your hash does result in the same value for multiple keys, you can use a chain-link table to handle this. That is, of your are not using a chain-link table already.

Any hashing algorithm will produce the same value for multiple keys. The chain-link table is only way to handle the one-to-many relataionship. You can also use a vector of vectors.
Aug 27 '07 #4
JosAH
11,448 Expert 8TB
Any hashing algorithm will produce the same value for multiple keys. The chain-link table is only way to handle the one-to-many relataionship.
That is not true; hash functions exist that are 'perfect', i.e. for any different pair
of keys k_i and k_j, h(k_i) != h(k_j); there even exist 'minimal perfect hash
functions where h(x) in [1, |x|]; but the set of keys k_i has to be known in
advance so h() can be computed.

kind regards,

Jos
Aug 27 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Markus Dehmann | last post by:
I have a class "Data" and I store Data pointers in an STL set. But I have millions of inserts and many more lookups, and my profiler found that they cost a lot of runtime. Therefore, I want to...
2
by: Jeff Thies | last post by:
I have this: var hash=new Array(); hash='some_value'; hash='some other value'; Whar do you call that in javascript? I know it's possible to define this in one line, but I've forgotten how....
47
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they...
4
by: flipdog | last post by:
Hello all, I didn't know there is a thread on hash function started in this newsgroup so reposted my posting from another group. Hope I can have some feedbacks. I am new to hash table. I came...
6
by: Chang | last post by:
How to get SHA1 or MD5 of a big file (+5MB - 20GB) as I can't read 20GB into memory. -- Chang.
12
by: wxs | last post by:
Many times we have a bunch of enums we have from either different enums or the same enum that will have various numeric values assigned. Rarely will there be collisions in numbering between the...
24
by: kdotsky | last post by:
Hello, I am using some very large dictionaries with keys that are long strings (urls). For a large dictionary these keys start to take up a significant amount of memory. I do not need access to...
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
2
by: joe shoemaker | last post by:
I would like to convert url into md5 hash. My question is that md5 hash will create collision at 2^64. If you do long(value,16), where value is the md5 hash string, would value returned from...
11
by: JWest46088 | last post by:
I'm having difficulty trying to figure out how to print a text file from a hash table one line at a time. I have the text file read into the hash table and can print the text file all at once, but I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.