-2

If you open a ".psd" file with an editor like Notepad, you cannot see the content of the file.

The result looks like this:

enter image description here https://i.stack.imgur.com/4GjJx.jpg

Is it possible to export (for example) a string with a special format which can not be read by users?

Grant Winney
  • 65,241
  • 13
  • 115
  • 165

3 Answers3

1

Why don't you try Encrypting the text ? See the selected answer here: Encrypting & Decrypting a String in C#

The data you are showing is binary data, and not text data.

There are two types of files: 1. Binary Files and 2. Text Files.

Text Files can be read by a text editor. Binary files look weird(like the one in the picture) in a text editor.

Community
  • 1
  • 1
Aniket Inge
  • 25,375
  • 5
  • 50
  • 78
1

Encoding, if you don't really care about encryption: It's easy to decode however

Byte[] buffer = Convert.FromBase64String(myBase64String1);
myBase64String2 = Convert.ToBase64String(buffer);

This SO question may be more appropriate. Its another fairly simple answer, not the stringest thing in the world, but nice.

I believe you should already have the RijndaelManaged Class and the top answer (by CraigTP) shows a simple wrapper to encrypt and decrypt strings with a pass phrase, which results in the same base64 encoding, but with the obvious advantage of a bit of encryption.

public static string Encrypt(string plainText, string passPhrase) and public static string Decrypt(string plainText, string passPhrase)

Community
  • 1
  • 1
Nathan Cooper
  • 6,262
  • 4
  • 36
  • 75
0

For a quick and dirty non-secure obfuscation, you can use binary object serialization. If you want to store this in another data format (like embed in XML) use base64 encoding to turn it into a "normal" string.

If you do this, note that the documents will not be guaranteed to be compatible across different .NET runtimes and versions... MS could change the binary serialization format at any time. Thus this is not a very robust solution.

Alternatively, you can serialize to a human-readable string (like XML or JSON), and encrypt it. Then it's guaranteed to work independent of the version of .NET you are running. If you are truly concerned about security, you probably want to invest in an obfuscation tool as well so they can't decompile and recover your encryption keys.

Clever Neologism
  • 1,322
  • 8
  • 9