Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to implement file checksum ?

Posted on 2004-08-09
7
Medium Priority
?
2,825 Views
Last Modified: 2012-06-21
Guyz,

My application uses a .xml file as input, and I need to make sure nobody has edited the file. Can we implement a checksum for this file? If so,
1.Where do I specify the file checksum in the .xml file
2.How to calculate the checksum for the .xml file and compare with the checksum found in the .xml file.

Any ideas?
Thnx!
0
Comment
Question by:kunjachan_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 11760190
You can create the file, then calculate the sum (for example getting the hash of the whole file string or only a part of it which is important) and save the check sum at the end of the file. When you read it, you can read the whole file, get the check sum that was saved inside it and then calculate again the checksum for the rest of the file (so the real contents, which was also secured when the file was saved). Then compare the check sums.

Instead of calculating a check sum, you can use a more advanced method, like sign the data. For more info have a look at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconCryptographicServices.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptographydsaclasstopic.asp
0
 
LVL 7

Expert Comment

by:psdavis
ID: 11761931
I like using MD5 for my checksums.

            MD5 pMD5 = new MD5CryptoServiceProvider( );
            byte[] resultHash = pMD5.ComputeHash( Encoding.ASCII.GetBytes( response ));
            string resultMD5 = Convert.ToBase64String( resultHash );
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 11761956
Note that using MD5 you can create a hash but you cannot sign it, so everybody can create the hash after signing the file
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 7

Expert Comment

by:psdavis
ID: 11761972
If all he is doing is making sure no one has edited the file, then the checksum idea is sound.  His biggest problem is that he wants to include the checksum inside the xml which invariably changes the checksum of the file.
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 400 total points
ID: 11762001
First, if I change the file, I will calculate a new hash, so the application will not notice that the file was changed - the hash is not enough.
Second, I already explained how the hash/signature can be included inside the file: make the hash always over the XML without the hash. This means you have <xml content><hash> and when the file is read, you remove the <hash> part, make a new hash of the <xml content> and verify the new hash with the <hash> part.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 11762006
Yep. Yer right.  I'm still pre-Diet Pepsi and not fully awake yet.
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 11762024
:-))
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question