Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone..

Am using Encrypting the text like this in WIN32:

C#
char textOut[25]="This text is for Encryption";
for(int q=0;q<=len;q++)
                    {
                        textOut[q]=textOut[q]^0xAA;
                    }
MessageBox(NULL,textOut,"",MB_OK);


Anyhow, Am getting Encrypted text in MessageBox.. But Am not getting how to Decrypt back..

Please help me.. And is there any better way to Encrypt & Decrypt.. If So do tell me..

Thanks in Advance..!
Posted
Comments
Sergey Chepurin 2-Apr-12 7:52am    
If even a creator of encryption does not know how to decrypt it, leave it unbreakable for crackers to get defeated.
Guru_C++ 2-Apr-12 7:59am    
Actually, In my Tool_a.exe Application, I have to Encrypt the Contents of the File.. And in Tool_b.exe application, I have to Decrypt the Contents of the file & it is viewed by only autheticated users.. So Am trying to Decrypt it..
Jochen Arndt 2-Apr-12 8:03am    
So you are using an encryption method without knowing what you are doing?
Sergey Chepurin 2-Apr-12 8:32am    
If you want to complete a single task without deep involvement, you can use CryptoAPI samples from Microsoft, for example:http://msdn.microsoft.com/en-us/library/aa382016(v=vs.85).aspx
But if you want to create something, read introductory materials available. For example, free chapters from "Handbook of Applied cryptography": http://msdn.microsoft.com/en-us/library/aa382016(v=vs.85).aspx

1 solution

Performing the XOR operation again would give you back the original character, try:
C++
char plain = 'A';
char encrypted = plain ^ 0xAA;
char decrypted = encrypted ^ 0xAA;
assert(plain==decrypted);
 
Share this answer
 
Comments
Resmi Anna 2-Apr-12 8:17am    
A 5!
CPallini 2-Apr-12 8:19am    
Thank you.
Guru_C++ 2-Apr-12 8:40am    
Thank you.. It is working..
CPallini 2-Apr-12 8:45am    
You doubted about, didn't you? :-D
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900