I need to store sensitive information (a symmetric encryption key that I want to keep private) in my C++ application. The simple approach is to do this:
std::
One method I recently tried is:
part1part2part1 and part2part1. It will verify the integrity of private data.MACRO to populate data:
Suppose, private data is of 4 bytes. We define a macro for it which saves the data with assignment instructions in some random order.
#define POPULATE_DATA(str, i0, i1, i2, i3)\
{\
char *p = str;\
p[3] = i3;\
p[2] = i2;\
p[0] = i0;\
p[1] = i1;\
}
Now use this macro in code where you need to save part1 and part2, as follows:
char part1[4] = {0};
char part2[4] = {0};
POPULATE_DATA(part1, 1, 2, 3, 4);
POPULATE_DATA(part2, 5, 6, 7, 8);