开发者

Protecting a Xml file

I'm fairly new to coding, and I just got help figuring out how to create a Xml file; now I want to know, is there a way to protect my Xml file from being edited?

I'm making a simple Command Prompt game, and I'm going to include an Xml file for info storage purposes. Although I don't want the user to be able to change the info contained in the file.. Is there a way to achieve this? It doesn't need to be extensive at this time, due t开发者_高级运维o the program only being a small project.

Anyway, I'm making the program with Visual Studio Pro 2010, and I'm coding it in C#. Thank you, for any help in advance.


the standard way to verify that parts of your xml has not been modified is to use XML_Signature

this msdn example shows how this is done with dotnet4


I would embed your XML file as a resource of your console application's assembly. The XML file will exist as an embedded resource and not as a seperate file that the user could potentially change. If the user isn't meant to edit a configuration file, don't even let him see it, modify it, or delete it.


look at this topic decrypt and encrypt

i have created my own Encrypter class based from this classes. then you can create it for yourself for next use


You could simply compress it, if you don't need a high level of security. You could use a standard format (ZIP, CAB), or just deflate the stream and store it as a binary file. See the doc and examples about this here: DeflateStream Class


You can't prevent anyone from editing your xml file but you can encrypt your xml file to protect your data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜