#ifndef encryption_h
#define encryption_h
#include <string>
#include <vector>
#include <cstdlib>
std::string encrypt(std::string to_be_encrypted)
{
std::vector<int> asciicodes;
unsigned int sum = 0;
for (unsigned int i = 0; i < to_be_encrypted.length(); i++)
{
sum+=int(to_be_encrypted[i]);
}
sum/=to_be_encrypted.length();
srand(sum);
char buf[50];
sprintf_s(buf, sizeof(buf), "%d%d%d", rand(), rand(), rand());
to_be_encrypted = "";
to_be_encrypted += buf;
return to_be_encrypted;
}
#endif
What do you think? It's been tested, works good enough. Only two minor artifacts.
"rawr" will produce the same as "awrr", because of the (irreversible!) averaging technique.
I'm not sure if the random generator will produce different results on different machines. I doubt it will, but still...
Sorry, it has been brought to my attention by Darkcoder that this is actually a hashing technique. Oh well.