.NET Framework Bookmark and Share   
 index > .NET Base Class Library > digitally signing a file
 

digitally signing a file

hi

how can i digitally sign a file , and verify in my code that the file is not tampered ?

thanks,
Ramana kumar.

Ramanakumar
The System.Security.Cryptography.Xml.SignedXml class provides signing and signature verification functionality for XML documents. See http://msdn.microsoft.com/en-us/library/ms229745.aspxfor signing and http://msdn.microsoft.com/en-us/library/ms229950.aspxfor verification.
Nicole Calinoiu
By the way, you may glad to see related demo in CodeFx,the demo is located in "Security" solution's "CSDigitalSignature" project.

Thanks,
Eric
Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang
Good luck with it. Maybe you ought to ask a question next time.

Hans Passant.
nobugz
Hi Kumar,
You didn't ask a question, what issue you encountered in your application?

Thanks,
Eric
Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang
Hi,
There are many ways to prevent your file from being tampered, for example, we can generate a MD5 value for the original file, when your partner get the file, they re-generate MD5 value and compare it with the original one to see whether the file is modified.
You can find Related Topics at the right of this page, there are some posts about how to digitally sign a MSI file, sign a .vsi package file, or text file.
So, we'd better make following things clear beforego further:
What's the file used for? for storing configuration or other data?
Isita XML file?text file?or other format?
Will your application modify the file at runtime?

Thanks,
Eric
Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang
Hi Eric,

it is an xml file,application will use this xml as schema andit won't modifythe file at runtime.

thanks,
Ramana kumar.
Ramanakumar
Hi,
The question is, if the file is not desired to be modified, why nottousesome static variables/types (for example, a sigleton instance which contains all schema information)instead of an external file (which is tend to be modified by others)?

Thanks,
Eric
Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang
this file is configurable depending on the client.

so iam not interested having aclass for each client.

thanks,
Ramana kumar.
Ramanakumar
Since the file is located on client machine, we cannot prevent other from reading/writing it. Even though hide it or encrypt it, people canalso access tothe file using some hack tools.
If the file is a configuration file for your application,just put it there and trustend users, or encrypt the file. following is some links about how to encrypt file:
http://www.codeproject.com/KB/security/fileencryptdecrypt.aspx;
http://www.codeproject.com/KB/security/DotNetCrypto.aspx;
http://support.microsoft.com/kb/307010;

Thanks,
Eric
Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang
Encryption is a good option.

But i am interested indigital signing as it will perfrorm better compared to encryption-decryption.

thanks,
Ramana kumar.
Ramanakumar
The System.Security.Cryptography.Xml.SignedXml class provides signing and signature verification functionality for XML documents. See http://msdn.microsoft.com/en-us/library/ms229745.aspxfor signing and http://msdn.microsoft.com/en-us/library/ms229950.aspxfor verification.
Nicole Calinoiu
By the way, you may glad to see related demo in CodeFx,the demo is located in "Security" solution's "CSDigitalSignature" project.

Thanks,
Eric
Please remember to mark helpful replies as answers and unmark them if they provide no help.
eryang

You can use google to search for other answers

Custom Search

More Threads

• Reading ConfigurationSection from a stream ?
• How to use Convert.ChangeType for RuntimeType?
• How can I have one and just one copy of my application running in the same time???
• display data
• Best practice or guidelines for writing an application to run tasks.
• formatting
• Problem generating Convert.ToString + dataRow using codeDom
• WindowsImpersonationContext
• Failing to Catch Exception
• Rijndael 256 bit blocksize