开发者

Save File Encryption in Bitcode

开发者 https://www.devze.com 2023-03-09 02:43 出处:网络
I hope that title isn\'t misleading; part of the problem I\'m having is I don\'t know how to ask the right questions. Anyway:

I hope that title isn't misleading; part of the problem I'm having is I don't know how to ask the right questions. Anyway:

I have a program that saves its state into a file and then loads it later. Just some basic stuff, integers, doubles, maybe a string here and there. So far I've been using .txt files, but I want to move onto another format. I know I can save with just about any extension I want (.sav .dat .map etc.) but opening it up in notepad just has the text info as expected, which means the user can fiddle all they want.

What I want to do is take the data I'm saving and convert it to binary or bitcode or whatever it's called so notepad (or any other text editor) will just put out random characters, like so: -‡Wk]s9µî,¯k^û.

I thought about rotating my characters before writing them out but that doesn't seem like it'll jumble it up as much as I want.

As you can probably already tell, I don't really know the correct name for the concept I'm trying to implement here. Sorry if that all seemed 开发者_开发技巧a little rambly.


If you're looking for a quick way to obfuscate your saved data, you could consider Base64 encoding. Here's some code that deals with this algo.

Please note that the Base64 encoding is not secure enough for storing sensitive info such as passwords, credit-card numbers and e-mails etc. However, for storing some program settings in an obfuscated manner so that the end-users don't mess with it, this ought to be sufficient.

You could consider writing your settings data in the binary mode (pass mode as b to the fopen function or use ios::binary flag with fstream objects).

0

精彩评论

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

关注公众号