문제

I have a 128 bit encryption key that I would like to break up into three parts that when XOR'ed together reproduce the key.

How do I do this?

도움이 되었습니까?

해결책

Pick two other 128 bit values at random (random_1 and random_2), then work out the equations to see how it works:

key ^ random_1 = xor_1

Now split xor_1 the same way:

xor_1 ^ random_2 = xor_2

Flipping that equation around, we get:

xor_1 = xor_2 ^ random_2

Now substitute back into the first equation:

key = random_1 ^ xor_2 ^ random_2

So your code will just do xor = key ^ random_1 ^ random_2 and you distribute everything but the key.

다른 팁

Just XOR the salt values in and then XOR them out to reverse it.

If key' = key ^ salt1 ^ salt2, then key = key' ^ salt1 ^ salt2.

It's pretty trivial to implement, but it's also pretty trivial to reverse engineer.

What are you trying to protect with this, and who are you trying to protect it from?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top