What is the fastest way to get the 'hash' (or CRC32 or whatever) of the
contents of an object
i don't care what's inside, I just want the 'hash' of its contents
(not to mixed with object.GetHashCode() which gives a hash code of an
instance, I want the hash of the data contents)
Evan 4 1390
AFAIK
MD5 Hash is fast and pretty reliable for its purpose CRC is more reliable
but also much slower
MD5 hash is often used to quickly compare 2 binary`s ( are they the same or
not , idea; for update/ file synchronization programs etc etc )
CRC is often used by compression program`s ( winzip , winrar etc etc ) to
check if they are exactly the same on byte level ( to check if the file not
has gone corrupted during deflation )
HTH
Michel
"Evan Camilleri" <ev**@holisticrd.com.nospamschreef in bericht
news:%2******************@TK2MSFTNGP04.phx.gbl...
What is the fastest way to get the 'hash' (or CRC32 or whatever) of the
contents of an object
i don't care what's inside, I just want the 'hash' of its contents
(not to mixed with object.GetHashCode() which gives a hash code of an
instance, I want the hash of the data contents)
Evan
Michel Posseth [MCP] <MS**@posseth.comwrote:
Strange ,,,,
Just one week ago , i was asked to create a network file synchronization
mechanism wich did not care about file versions
"file remote different as the local version , copy it local" as we are
talking about hundreds of files and a total size of + 100 MB
i needed a fast way to check these files .
So i went digging on the web wich algorythm would be the fastest and found
my previous conclusion on various websites
My project is finished and performs superb , but you are telling me now that
CRC ought to be faster but less reliable ??
It *may* be faster, depending on the exact implementation. However,
it's unlikely that the hash performance is going to be significant
compared with the IO cost. Hashing 100MB of data is likely to be very
quick with either algorithm.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
>However,
it's unlikely that the hash performance is going to be significant
compared with the IO cost.
Yes ... that is a good one .. in my situation the cost of copying a file
that did not need replacement
However it seems that i got my implentation right as MD5 hash would be more
reliable but probably a bit slower as a CRC
and in my situation it turned out thet this is exactly what i need cause it
is more costly to copy the file over the intranet to the client
So i guess i had a lucky day when i wrote it :-)
regards
And thanks for sharing
Michel
"Jon Skeet [C# MVP]" <sk***@pobox.comschreef in bericht
news:MP*********************@msnews.microsoft.com. ..
Michel Posseth [MCP] <MS**@posseth.comwrote:
>Strange ,,,,
Just one week ago , i was asked to create a network file synchronization mechanism wich did not care about file versions "file remote different as the local version , copy it local" as we are talking about hundreds of files and a total size of + 100 MB i needed a fast way to check these files .
So i went digging on the web wich algorythm would be the fastest and found my previous conclusion on various websites
My project is finished and performs superb , but you are telling me now that CRC ought to be faster but less reliable ??
It *may* be faster, depending on the exact implementation. However,
it's unlikely that the hash performance is going to be significant
compared with the IO cost. Hashing 100MB of data is likely to be very
quick with either algorithm.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
On Sep 4, 3:29 pm, "Evan Camilleri" <e...@holisticrd.com.nospam>
wrote:
I actually wanted to see some code since I cannot find how to get MD5 or CRC
for the object's data
As Peter said, there's no such concept as "the object's data" that
makes taking an MD5 hash sensible in all cases.
What would the MD5 of a NetworkStream be? Would you have to read all
its contents to find out?
Jon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Clemens Hoffmann |
last post by:
Hello,
i have a nasty problem with object identity in
hash tables. I try to use different objects as keys.
It failed bacause i cannot identify object propperly.
Different objects with the same...
|
by: Bijay Kumar |
last post by:
Hi Guys,
I was going through the source code of Object.cs in rotor. What I found is
Equals() implemented as follows:
public extern virtual bool Equals(Object obj);
What I don't...
|
by: Peter Nofelt |
last post by:
Hey all,
I am running into an issue. My situation is that I wish to copy the
contents of one listbox to an array, sort it by innerText value, and
write the sorted options into a new listbox.
...
|
by: ajm |
last post by:
Hi All,
given an object file is there any way (or tool) to determine which
compiler created it ?
tia,
A.
|
by: Bijay Kumar |
last post by:
Hi Guys,
I was going through the source code of Object class (Object.cs in rotor). What I found is
Equals() implemented as follows:
public extern virtual bool Equals(Object obj);
What...
| |
by: Michael H |
last post by:
Hi all,
I guess I don't fully understand how a SHA1 hash value is calculated
in C# / .NET for a large file... I'm trying to calculate SHA1 values
for large files that are much larger than my...
|
by: Stephan Keil |
last post by:
Hi all,
I am a novice with .NET and I am wondering if there is something like an
"identity value" of an object. I mean something like the object's address
in C++ or C, i.e. a fixed unique value...
|
by: Evan Camilleri |
last post by:
What is the fastest way to get the 'hash' (or CRC32 or whatever) of the
contents of an object
i don't care what's inside, I just want the 'hash' of its contents
(not to mixed with...
|
by: Al Meadows |
last post by:
I'm using a generic Dictionary object where it is described as:
Dictionary<this, thatstuff = new Dictonary<this, that>()
Where THIS is a class with several property values.
This works fine...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
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...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |