对文件进行编码
这个问题解释起来有点棘手。我想创建一个文件,比如说 .test 文件。现在,创建和编写它非常容易,但我想对信息进行编码,这样我只能用测试程序来解释信息。 因此,该测试程序将能够创建和读取 .test 文件。关键是,只有该程序可以读取该文件,您无法仅通过使用记事本打开该文件来真正解释该信息,因为它不可读。
我只是想要一些关于如何实现这一目标的指导。如果您确实不明白我刚才所说的内容,我想知道如何创建类似于 BitTorrent 中使用的 Bencode 的东西或者它是如何工作的。
This one is a little tricky to explain. I would like to create a file, lets say, a .test file. Now, this is ridiculously easy to create and write, but I would like to encode the information so I could only interpret the information with the Test Program.
So, this Test Program would be able to create and read the .test files. And the point is that, only that program can read the file, you can't really interpret the information just by opening the file with Notepad as it wouldn't be read-able.
I would just like some direction as to how I could accomplish this. If you really didn't understand what I just said, I would like to know how to create or how does it work something similar to Bencode used in BitTorrent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您确实担心文件的安全性,可以对其内容进行加密。有几个第三方库,例如 ezPyCrypto 和 pyDes 使其易于实施。
If you're really worried about the security of the file, you could encrypt its content. There are several third party libraries such as ezPyCrypto and pyDes that make it simple to implement.
如果您想要一个非常简单的版本,请使用 python 的 base64 模块。该文件将无法再在记事本中打开,但如果您知道自己在做什么,则可以轻松解码。
如果您确实想阻止任何其他程序对其进行编码:请不要这样做。你可能会花费很多精力,但你真正能完成的唯一一件事就是惹恼想要数据的人。
If you want a really simply version, use python's base64 module. The file won't be recognizable opening in notepad anymore, but it'll be easy to decode if you know what you are doing.
If you actually want to prevent any other program from being able to encode it: don't. You can spend a lot of effort and the only thing you can really accomplish is annoying the person who wants the data.
您需要确定是要编码还是加密:
http://danielmiessler.com/study/encoding_vs_encryption/
You need to determine whether you want en-coding or en-cryption:
http://danielmiessler.com/study/encoding_vs_encryption/