views:

29

answers:

1

The problem is that I want to get the original values of B, or the original value of C or A. Here is the code:

    Dim strA As String = "A"
    Dim strB As String = "B"
    Dim strC As String = "C"
    Dim result As Byte = 0

    ' Fetch the byte character code of strings and Xor them all into the result in a sequence.
    result = result Xor AscW(strA)
    result = result Xor AscW(strB)
    result = result Xor AscW(strC)

    ' the final result value is 64

How to do this? Please help me with the correct solution to this problem. If there can be another parameter which when applied with a formula may reveal the original values: "A", "B", "C". Thank you.

+1  A: 

If I understand your question correctly, this is simply not possible. There are multiple ways to split result back into strA, strB and strC.

To make it easier to see why, consider addition instead. Suppose you start with A = 5, B = 6 and C = 7. The sum is 18. Now suppose you start with A = 1, B = 1 and C = 16. The sum is still 18. Bottom line: if all you have is "18" there's no way to split it back, because multiple inputs give the same output.

romkyns
If I know one source value, then is it possible?
Tush
@Tush no, you still have the same problem. 1 + 9 = 10, but also 2 + 8 = 10, and 3 + 7 = 10, and 4 + 6 = 10, etc... XOR has the same property.
romkyns
Is there any other way to do what I require? Please tell.
Tush
@Tush I'm telling you, it's **IMPOSSIBLE**. Not like "it's very hard", or "you need lots of dollars" or whatever. It's a _mathematical impossibility_. (assuming of course that "what you require" is to reverse the XOR operation).
romkyns
@Tush Well actually, if you allow 1 known value then I suppose you could bump that up to 2. If you know two of the three then the third one can be calculated. If that's what you're after then please edit the question to explain this.
romkyns
@Tush: This is getting funny. You can ask this a 100 times more on SO, but it will still be IMPOSSIBLE.
0xA3