Gold mine of Visual C++ tricks!
How to generate the hash key of given data?
![]()
Hashes are everywhere. Hash is small key generated from a bulk chunk of data. The hashes are useful in many ways. They are used for table lookups and data comparison. Yes! As you think now, hash table is one among them which utilizes hashes for high speed lookups. Well, thats a good, But how to generate the hash of a chunk of data?
![]()
You can use the function – HashData(). See the following code snippet.
#include "Shlwapi.h"
...
// Buffer for hash Key.
const int MAX_HASH_LEN = 256;
BYTE Hash[MAX_HASH_LEN] = {0};
// Chunk of Data.
char* pData = "Hello World";
// Generate Hash Key.
HashData( (LPBYTE) pData,
strlen( pData),
Hash,
MAX_HASH_LEN );
![]()
Do you know that in real world, Hash means – “Chop and Mix”. Have a look at Wiki -
http://en.wikipedia.org/wiki/Hash_function#Origins_of_the_term
BTW, Don’t forget to add Shlwapi.lib to project settings.
![]()
Targeted Audience – Beginners.
| Print article | This entry was posted by Jijo Raj on June 27, 2008 at 6:57 pm, and is filed under Windows APIs. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |


