Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i need to create method for personal encoding like this

for example i have string parameter A = "P@ssw0rd" and B = 0xffa1
C = A XOR B
C is my result
it's clear
but in decoding
what operator i have to use to get A from C and B????
A = C (what operator) B ??????

What I have tried:

string A = "P@ssw0rd";
string B = 0xffa1;
C = A XOR B
Posted
Updated 2-Oct-17 7:10am

The same one!
A XOR B == C
C XOR B == A

But TBH XOR is not an good encryption algorithm, it's far, far too easy to break - and you shouldn't be encrypting passwords anyway! You should Hash your passwords, not encrypt them: Password Storage: How to do it.[^]
 
Share this answer
 
Bitwise the XOR operation is reversible:

(a xor b) xor b = a

hence, if probably done, you can reverse the XOR 'ecryption' simply XORing again with the same key.
 
Share this answer
 
Comments
Roozbeh Amiressami 2-Oct-17 9:20am    
thank you so much
i know but its a college project
Quote:
but in decoding
what operator i have to use to get A from C and B????

Same
A second xor cancel the first one.
So when you have C=A xor B, you will also have A=C xor B and B=A xor C with same values for A,B,C.
 
Share this answer
 

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