473,444 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MD5 or other checksum

Gents,

I need the checksum of an xml file in order to verify that no changes has
been made to the file. How is this done.

Second, is it possible to 'embed' the MD5 checksum inside the very same
file. I guess not but perhaps if it is possible to make a partial checksum
not based on the first X characters of the file.

Thank you very
Nov 17 '05 #1
2 10011
private void button16_Click(object sender, EventArgs e)
{
using ( FileStream fs =
System.IO.File.OpenRead(@"c:\windows\notepad.exe") )
{
MD5 m5 = MD5.Create();
byte[] hash = m5.ComputeHash(fs);
string base64Hash = Convert.ToBase64String(hash);
Console.WriteLine("Base64 MD5 hash of Notepad.exe: " + base64Hash);
}
}

You can do the same kind of thing with SHA1, SHA128, etc.

--
William Stacey [MVP]

"Jesper" <Je****@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
Gents,

I need the checksum of an xml file in order to verify that no changes has
been made to the file. How is this done.

Second, is it possible to 'embed' the MD5 checksum inside the very same
file. I guess not but perhaps if it is possible to make a partial checksum
not based on the first X characters of the file.

Thank you very

Nov 17 '05 #2
Jesper <Je****@discussions.microsoft.com> wrote:
I need the checksum of an xml file in order to verify that no changes has
been made to the file. How is this done.

Second, is it possible to 'embed' the MD5 checksum inside the very same
file. I guess not but perhaps if it is possible to make a partial checksum
not based on the first X characters of the file.


That wouldn't be particularly hard to do - open the file (as a stream),
read the first however-many bytes, then pass the stream to
MD5.ComputeHash.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #3

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

Similar topics

12
by: Mercuro | last post by:
Hello i'm looking for a simple way to checksum my data. The data is 70 bytes long per record, so a 32 byte hex md5sum would increase the size of my mysql db a lot. I'm looking for something...
2
by: pradeep | last post by:
I have 2 data files, DATA1 and DATA2 , both same. My task is to: Open DATA1, compute the checksum and put it in the end of the file(don't bother about boundary conditions).close DATA1 Open...
4
by: Abby | last post by:
I have an array which contain Hex no. in each position. For examples, unsigned char data; data = 0x00; data = 0x01; data = 0x02; data = 0xE; data = 0xEF; --> This is the checksum value
2
by: Abby | last post by:
I need to do 8 bits 2's complement checksum, so I wrote code in order to see if the checksum calculation is correct. ===========================================================================...
6
by: Kevin | last post by:
I'm on Sun 0S 5.8 and need to calculate the checksum of certain sections in an ELF binary file. Specifically .text to .rodata. I'm able to parse through to the program header table and then find...
3
by: Andrus | last post by:
Device connected to serial port accepts data packets in the form 02 0x57 ll ll 00 00 00 00 dd..dd cc cc 02 (1 byte ) is message prefix 0x57 (1 byte) is message type (W=Write) ll ll ( 2 bytes)...
1
by: Terry | last post by:
I'm trying to calculate the checksum for UDP packet. The algorithm itself is not difficult (lots of examples out there), but what I'm having the most trouble with is determining the byte order...
15
by: rjfjohnson | last post by:
Hey, I am trying to communicate with serial device and I need to know the method used to calculate the 1digit checksum. I have a commercial program that can communicate with the device, and a...
4
by: Rain | last post by:
hi, need help here, does anyone know how to use or does any one have the code for checksum? I want to checksum a string to be sent using udp and checksum it again when received.. does anyone...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.