C#加密的XML文件 [英] c# encrypt xml file

查看:111
本文介绍了C#加密的XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

告诉我加密的XML文件的最简单方法。它是用于一些配置文件,并且不希望人们摆弄它周围。安全不是一个问题,因为它是一个专用的工具。

Tell me the easiest way to encrypt an XML file. It is a file used for some configurations and don't want people mucking around with it. Security is not an issue as it is a private tool.

推荐答案

如果你不关心安全性,只是保存文件用哈希在一起。即:

If you don't care about security, just save the file together with a hash. Ie:

your.xml

your.xml.hash

your.xml and your.xml.hash

您可以使用System.Security.Cryptography.MD5Managed例如。它只是为了保存XML文件,然后保存文件本身的哈希值。读取时,只计算哈希,用什么保存的比较,然后用你的XML文件作为常规。

You can use System.Security.Cryptography.MD5Managed for example. It's just to save the xml file, and then save a hash of the file itself. When reading, just calculate the hash, compare with what's saved, and then use your xml file as regular.

当然,在XML文件中的信息未加密,这是可能的阅读,但如果您编辑文件,然后散列不会是正确的,你的程序将探索尝试。保持简单:)

Of course, the information in the xml file isn't encrypted, it's possible to read, but if you edit the file then the hash won't be correct, and your program will discover the attempt. Keep it simple :)

这篇关于C#加密的XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆