Looking for techniques for taking a std::string and obfuscating it, using a key such that all calls to:
std::string obfuscate(const char *pInputStr, int minOutputLen, const char *pKeyStr);
*pInputStr
will be a string which is up to 40 characters, and I want to map it to a human readable string of minOutputLen
length.
Multiple calls with the same inputs should return the same value. Basically looking for a way where I can display a set of strings, and depending on if I'm in "obfuscate" mode, certain values will be encoded so that the user cannot reverse engineer the value.
Example: Let's say I have a structure:
class Person
{
public:
std::string FirstName;
std::string LastName;
std::string SSNumber;
}
What I would like to do is something like this:
int main()
{
Person p = {"Bob", "Needermyer", "12345678"};
std::cout << "Display without obfuscation" << std::endl;
std::cout << "First: " << p.FirstName << std::endl;
std::cout << "Last: " << p.LastName << std::endl;
std::cout << "SS: " << p.SSNumber << std::endl;
std::cout << "Display to user, but obfuscate the data" << std::endl;
char *pKey = "abcdefg";
std::cout << "First: " << obfuscate(p.FirstName, 10, pSeed) << std::endl;
std::cout << "Last: " << obfuscate(p.LastName, 10, pSeed) << std::endl;
std::cout << "SS: " << obfuscate(p.SSNumber, 10, pSeed) << std::endl;
}
Output like this:
Display without obfuscation
First: Bob
Last: Needermyer
SS: 12345678
Display to user, but obfuscate data
First: 4Tf7*f3f$r
Last: G9r3sfgvsr
SS: 9cd2832sd2
This would allow all logic in the program to continue to work as normal, but would change the display of the data.
For example, I could use something similar to ROT13, but ideally an algorithm that you can't reverse engineer without the seed/key.