Click to See Complete Forum and Search --> : What hashing algorithm outputs numbers only?


wkatz
September 10th, 2006, 11:13 AM
Hi, Gurus. What hashing algorithm outputs hash value as numbers only? For example, if you pass a “John Q. Public” it will output 23324. If there is no such hashing, how hard is it to hire somebody to write a fairly quick one? It could be some fast hashing and then another function that creates numbers. Much obliged. wkatz.

wildfrog
September 10th, 2006, 12:16 PM
What hashing algorithm outputs hash value as numbers only?Most of them? While most hash algorithms produce a numeric result, they're often printed as hexadecimal numbers (0-9, A-F). But they're still plain numbers.

You can find some algorithms here (http://www.partow.net/programming/hashfunctions/index.html).

- petter

ovidiucucu
September 10th, 2006, 12:19 PM
[ Redirected thread ]

MikeAThon
September 10th, 2006, 02:03 PM
Are you looking for a simple hashing function, for use in generating a key for a map based on strings?

If so, then I have successfully used the following, which generates the key needed by the MFC CMap collection class, based on CString entries:
// implementation of hash function

template< > UINT AFXAPI HashKey( CString& key )
{
LPCTSTR pp = (LPCTSTR)(key);
UINT uiRet = 0;
while (*pp)
{
uiRet = (uiRet<<5) + uiRet + *pp++;
}

return uiRet;
}
It's of course not gauranteed to return unique results, but for a map it doesn't need to anyway.

Mike

kumaresh_ana
September 12th, 2006, 01:59 AM
Hi, Gurus. What hashing algorithm outputs hash value as numbers only? For example, if you pass a “John Q. Public” it will output 23324. If there is no such hashing, how hard is it to hire somebody to write a fairly quick one? It could be some fast hashing and then another function that creates numbers. Much obliged. wkatz.
Hashing functions like SHA, MD5.... which are used in crypto treat the input as a sequece of bytes or blocks of byte. So, the output of these functions will always be string of bytes which can be conviniently called numbers. But these are alittle heavy functions because they are meant to be real oneway hash functions. If the requirements demands such needs go for them.

Lee Cheon-Sin
September 19th, 2006, 11:03 PM
Basically all hashing algorithms give numbers as outputs. You just have to decide how large the number should be at max. CRC32, would give you a 32-bit hash, which gives you a range of 0x00000000 to 0xffffffff (0 to 4,294,967,295) as possible outputs.