I’m going to Serialize a class with CString and int-members to a file and then transfer it over the network. One of the members is a password-like one and I would like it to be encrypted before the serialization.
the easyest way is XOR encription, but it is not the best.
For each sumbol you apply a XOR per bit
for example you have password key qwerty. And you have string, "hello my baby, I want to see you"
you encript like this:
hello my baby, I want to see you
^=
qwertyqwertyqwertyqwertyqwertyqw|erty
like this:
str[0] ^= q;
str[1] ^= w;
str[3] ^= e;
....
and you obtain some encripted string:
dfsdfsdfasddadfasdfwtkoeyjlkruju
after you send the string you can uncrypt it by aplaying XOR again:
dfsdfsdfasddadfasdfwtkoeyjlkruju
^= qwertyqwertyqwertyqwertyqwertyqw|erty
The operation will be the same:
obtained_str[0] ^= q;
obtained_str[1] ^= w;
obtained_str[3] ^= e;
.....
and you will obtain the originally created string:
hello my baby, I want to see you
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.