mardi 11 janvier 2022

Generate string by switching ASCII code (extended)

I have a list of strings that were "encrypted" with a simple char code switching. To make them readable I need to increase each character code by 7. The problem is that those codes can be above 127 (extended ASCII). I'm iterating each seed string and trying to produce a new string like this

string result = "";
for(std::string::iterator it = myEncryptedWord.begin(); it != myEncryptedWord.end(); ++it) 
{
   unsigned char myC = *it;
   result+= char(myC+7);
}

It does not work for codes above 127 (characters like áóõã...). Needless to say that I can't control the original string list and change this poor "encryption".

Aucun commentaire:

Enregistrer un commentaire