문제

I'm searching for a way to do string mangling in C/C++. The requirements for the software is that no plain text strings exist(No encryption needed, just mangling) and I'm attmping to figure out the path of least resistance for this requirement. Obfuscation and mangling of class names is covered through relatively easy to acquire tools but the string mangling seems to be a harder hurdle to jump.

I am comfortable with post processing of the software if that is the standard answer. Are their tools already written to do this or do I need to hack up my own scripts to munge strings?

Also I understand that mangling of the strings at rest is not really true security. I get that, and you likely get that but hey its a requirement that was placed on the software so I have to meet it.

Thanks! steph

도움이 되었습니까?

해결책

A simple ROT13 Encrypter/Decrypter. No need to write a decryption function. Its called ROT13 because it simply rotates 13 characters back to its original state.

#include <iostream>
using namespace std;


  //encrypt or decrypt string
void ROT13_Encrypt_Decrypt_String(char str[]){

for( int i=0; str[i] != '\0'; i++ ){
    if(str[i] >= 'a' && str[i] <= 'm'){
        str[i] += 13;
    }

    else if(str[i] > 'm' && str[i] <= 'z'){
        str[i] -= 13;
    }

    else if (str[i] >= 'A' && str[i] <= 'M'){
        str[i] += 13;
    }

    else if(str[i] > 'M' && str[i] <= 'Z'){
        str[i] -= 13;
    }

}
}


int main()
{
    char mystring [] = "Hello World!";
    cout << "Original string: " << mystring << endl;

    //encrypt   
    ROT13_Encrypt_Decrypt_String(mystring);   

    cout << "Encrypted string: " << mystring << endl;

    //decrypt  
    ROT13_Encrypt_Decrypt_String(mystring);

    cout << "Decrypted string: " << mystring << endl;

    return 0;
}

Output:

Original string: Hello World!
Encrypted string: Uryyb Jbeyq!
Decrypted string: Hello World!
Press any key to continue

다른 팁

If you are dealing with ASCII text, simply set the 7th bit on each character to de-plain-text it, then unset it to turn it into plain-text.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top