Welcome to Mandalay Technological University Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Welcome to Mandalay Technological University Forum

ဴမန္မာအင္ဂဵင္နီယာမဵားဖိုရမ္
 
HomePortalGallerySearchLatest imagesRegisterLog in

 

 Hash table design

Go down 
AuthorMessage
chochotinngwe
LEVEL '0'
LEVEL '0'



Female
Number of posts : 7
Age : 42
Location : Oxford,uk
Batch if MIT (if not simply fill YIT) : last batch
Registration date : 2006-10-28

Hash table design Empty
PostSubject: Hash table design   Hash table design Icon_minitimeSun Oct 29, 2006 2:41 am

Dear all,
I would like to create a hash table using my own hash functions.If somebody know the books,links,website.. pls share me.
many thanks,
cctn
Back to top Go down
ZawMinHt
Guest
Anonymous



Hash table design Empty
PostSubject: Re: Hash table design   Hash table design Icon_minitimeSun Oct 29, 2006 3:43 am

There are many Hashing alogrithms in use today. Some strong hashing alogrithms are 'Message Digest' (MD4, MD5), secure hash alogrithm (SHA-1), various DES, etc. They all fall under category of cryptographic services. They are intended for secured environments. But they normally take some level of processing power (although negligible on modern PCs). You can choose a simpler solution such as checksums (CRC) . Cyclic Redundancy Check a.k.a CRC32 is not quite a secure one but can provide enough integrity checks on the contents. If you want to learn more on these :

http://en.wikipedia.org/wiki/Cryptographic_hash_function
http://en.wikipedia.org/wiki/Cyclic_redundancy_check

I think STL (standard template library ) won't be the choice since you want to create your own routing.

If your hash table just for use such search ,sort, etc, you can use the following snippet shown below. It is a very simple hashing technique by XOR.ing the integer values. It is very fast as well.

int ILibGetHashValue(void *key, int keylength)
{
int HashValue=0;
char TempValue[4];

if(keylength<=4)
{
//
// If the key length is <= 4, the hash is just the key expressed as an integer
//
memset(TempValue,0,4);
memcpy(TempValue,key,keylength);
// MEMCHECK(assert(keylength<=4)Wink // !! you can neglect this line

HashValue = *((int*)TempValue);
}
else
{
//
// If the key length is >4, the hash is the first 4 bytes XOR with the last 4
//
memcpy(TempValue,key,4);
HashValue = *((int*)TempValue);
memcpy(TempValue,(char*)key+(keylength-4),4);
HashValue = HashValue^(*((int*)TempValue));
//
// If the key length is >= 10, the hash is also XOR with the middle 4 bytes
//
if(keylength>=10)
{
memcpy(TempValue,(char*)key+(keylength/2),4);
HashValue = HashValue^(*((int*)TempValue));
}
}
return(HashValue);
}
Back to top Go down
chochotinngwe
LEVEL '0'
LEVEL '0'



Female
Number of posts : 7
Age : 42
Location : Oxford,uk
Batch if MIT (if not simply fill YIT) : last batch
Registration date : 2006-10-28

Hash table design Empty
PostSubject: Re: Hash table design   Hash table design Icon_minitimeSun Oct 29, 2006 4:48 am

Many Thanks bro ZawMinHtut.
Back to top Go down
Sponsored content





Hash table design Empty
PostSubject: Re: Hash table design   Hash table design Icon_minitime

Back to top Go down
 
Hash table design
Back to top 
Page 1 of 1
 Similar topics
-
» pls advise me...
» To learn Web Design
» Fashion Design And Coach New Arrival

Permissions in this forum:You cannot reply to topics in this forum
Welcome to Mandalay Technological University Forum :: Computer Software and Programming :: C, C++, Visual C++, Basic, Visual Basic-
Jump to: