kunjachan_
asked on
how to implement file checksum ?
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!
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!
I like using MD5 for my checksums.
MD5 pMD5 = new MD5CryptoServiceProvider( );
byte[] resultHash = pMD5.ComputeHash( Encoding.ASCII.GetBytes( response ));
string resultMD5 = Convert.ToBase64String( resultHash );
MD5 pMD5 = new MD5CryptoServiceProvider( );
byte[] resultHash = pMD5.ComputeHash( Encoding.ASCII.GetBytes( response ));
string resultMD5 = Convert.ToBase64String( resultHash );
Note that using MD5 you can create a hash but you cannot sign it, so everybody can create the hash after signing the file
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yep. Yer right. I'm still pre-Diet Pepsi and not fully awake yet.
:-))
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