Sometimes it is necessary to hide the user sensitive settings like the passwords/ login etc in your application settings file (registry), so you have to make it somehow unreadable applying some encryption (scrambling the text). I’m only going to write two simple and fast ways to achieve that:
1. Binary Shift : the simplest of all, you just increase or decrease a char by a number:
void BinaryShift(char *s,int n)
s[i] += n;
2. XOR : Exclusive OR encryption, this encryption while extremely simple, is nearly unbreakable (it’s weak against pattern attacks) .
[cpp]int xorme(char *string, char *key)
for(int x=0; string[x]!=’\0′; x++)
xor an entire structure like this:
[cpp]void xorstruct(char *str,char *key,int sz)
for(int x=0; str[x]!=’\0′; x++)
Use it like:
There are strong algorithms like AES (Rijndael) that has been designed with the state of art in the cryptographic research an it will definitely keep away attackers that are not so skilled in reversing it (or not: Block ciphers sensitive to Groebner Basis Attacks. ) .
If you are mybe ‘paranoia’ about the sensitive data or your project requires strong encryption you may try the open source library Crypto++ and use different algorithms.
Other ways to encrypt your data :
Fast Simple Secure Encryption Routine
File Encryption ASG, SG, RC4
Encryption using the Win32 Crypto API
FileCrypt (Rijndael, Blowfish, TEA, XOR256)
A C++ Implementation of the Blowfish Encryption/Decryption method
Portable, Rinjdael (AES) Based Stream Cipher Class
Good luck in securing your private data.