473,395 Members | 2,192 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,395 software developers and data experts.

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

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.

Jan 18 '07 #1
5 6106
fo*****@laposte.net wrote:
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

Jan 18 '07 #2
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.

Jan 18 '07 #3
Look for "message digest" - maybe it will help you.

Serge
http://www.sergejusz.com

fo*****@laposte.net wrote:
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.
Jan 21 '07 #4
On 18 Jan 2007 12:13:38 -0800, for.fun wrote:
>I need to calculate the hash code of a text file (in order to uniquely
identify a file)
Start here:
http://en.wikipedia.org/wiki/Cryptog..._hash_function
Jan 21 '07 #5
I cut/paste the C code from the RFC 1321 (http://tools.ietf.org/html/
rfc1321) and it works fine.
Thanks for the links.
On 21 jan, 13:34, rpbg...@yahoo.com (Roland Pibinger) wrote:
On 18 Jan 2007 12:13:38 -0800, for.fun wrote:
I need to calculate the hash code of a text file (in order to uniquely
identify a file)Start here:http://en.wikipedia.org/wiki/Cryptog..._hash_function
Jan 30 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
15
by: Viviana Vc | last post by:
How can I programatically do the equivalent of the following: cacls "C:\Program Files\test" /T /G Everyone:f ? Thanks, Viv
6
by: Csaba Gabor | last post by:
I'd like to be able to pass a key1/value1 pair into a function and have that function have a local variable by the name of key1 to which value1 is assigned. for example, I'd like to call...
3
by: Paul Spielvogel | last post by:
I need to compute the MD5 hash on VERY large files 500mb to 4gb+ I have found two ways but neither one of them does what i need. Private Function ComputeDataMD5(ByVal path As String) As String...
0
by: richardkreidl | last post by:
I have the following hash script that I use to compare two text files. 'Class Public Class FileComparison Public Class FileComparisonException Public Enum ExceptionType U 'Unknown A 'Add...
1
by: Peter Alberer | last post by:
Hi there, i have a problem with a query that uses the result of a plsql function In the where clause: SELECT assignments.assignment_id, assignments.package_id AS package_id,...
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: cremoni | last post by:
STL has a hash function documented here: http://www.sgi.com/tech/stl/hash.html What header do I include? I can't find it defined anywhere in the MSVC headers. I'm using MSVC8, BTW. Sorry if...
139
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.