Storing encrypted data with libconfig

I use libconfig to create a configuration file, and one of the fields is the contents of the encrypted file. The problem arises because there are several character screens in the file that partially preserve the contents. What is the best way to store this data to avoid accidental failure? Convert to Unicode? Any suggestion?

+4
source share
2 answers

You can either use URL encoding , where each character without an ASCII character is encoded as a character %followed by two hexadecimal digits, or you use base64 encoding , where each set of 3 bytes is encoded into 4 ASCII characters (3x8 bits → 4x6 bits).

For example, if you have the following bytes:

00 01 41 31 80 FE

You can encode the URL as follows:

%00%01A1%80%FE

Or you can encode base64 like this: 0-25 = AZ, 26-51 = az, 52-62 = 0-9, 62 =., 63 = /:

(00000000 00000001 01000001) (00110001 10000000 11111110) -->
(000000 000000 000101 000001) (001100 011000 000011 111110) 

AAJBNYD.
+2
source

The standard for encoding binary data in text used by uuencode is now the base. Both use the same paradigm: a byte uses 8 bits, so 3 bytes use 24 bits or 4 6 bit characters.

uuencode 6 32 ( ascii ), 32-96 = > ascii, , , ,

base64 64 0 63 ( =:;,'"\*(){}[], ...):

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

(=) , , 4.

, C, ++ uuencode, 64 , , SO: base64 () C?

+1

All Articles