Where to find a C++ hash code function for text files ?

F

for.fun

Hi everybody,

I need to calculate the hash code of a text file (in order to uniquely
identify a file)
My program has to run under Windows and under Unix (Solaris)

That's why I am looking for a Standard C++ function which would
calculate the hash value.

Does anyone knows if such a function exist ?

Under Windows, I looked in the STL and found the "hash_value(const char
*)" function but unfortunately, it returns the same value for strings
which have a few differences.

Please tell me if there is a standard and reliable C++ hash function.
If not, please send me a link or another forum where I can get the
answer.

Thanks in advance.
 
M

mlimber

I need to calculate the hash code of a text file (in order to uniquely
identify a file)
My program has to run under Windows and under Unix (Solaris)

That's why I am looking for a Standard C++ function which would
calculate the hash value.

Does anyone knows if such a function exist ?

Under Windows, I looked in the STL and found the "hash_value(const char
*)" function but unfortunately, it returns the same value for strings
which have a few differences.

Please tell me if there is a standard and reliable C++ hash function.
If not, please send me a link or another forum where I can get the
answer.

There is no standard hash function (yet), and the one you found is
likely a part of the STL that was developed by SGI but didn't make it
into the standard library and is thus considered a non-standard
extension. In any case, I think if you want to consider a relatively
large file, a checksum or something of that sort would probably be
better. Google for it.

Cheers! --M
 
F

for.fun

mlimber a écrit :
There is no standard hash function (yet), and the one you found is
likely a part of the STL that was developed by SGI but didn't make it
into the standard library and is thus considered a non-standard
extension. In any case, I think if you want to consider a relatively
large file, a checksum or something of that sort would probably be
better. Google for it.

Thanks for your help and for orienting me to checksums.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top