开发者

Encoding a file

开发者 https://www.devze.com 2023-02-18 04:52 出处:网络
This one is a little tricky to explain. I would like to create a file, lets say, a .test file. Now, this is ridiculously eas开发者_JAVA技巧y to create and write, but I would like to encode the informa

This one is a little tricky to explain. I would like to create a file, lets say, a .test file. Now, this is ridiculously eas开发者_JAVA技巧y 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.


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.


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.


You need to determine whether you want en-coding or en-cryption: http://danielmiessler.com/study/encoding_vs_encryption/

0

精彩评论

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