logoalt Hacker News

danhautoday at 8:26 AM4 repliesview on HN

> Are there other XOR tricks?

Yes, error correction.

You have some packets of data a, b, c. Add one additional packet z that is computed as z = a ^ b ^ c. Now whenever one of a, b or c gets corrupted or lost, it can be reconstructed by computing the XOR of all the others.

So if b is lost: b = a ^ c ^ z. This works for any packet, but only one. If multiple are lost, this will fail.

There are way better error correction algorithms, but I like the simplicity of this one.


Replies

ameliustoday at 9:37 AM

XOR is also great for storing copyrighted works without liability.

a = the bits of some song or movie

b = pure noise

Store c = a^b.

Give b to a friend. Throw away a.

Now both you and your friend have a bit vector of pure noise. Together you can produce the copyrighted work. But nobody is liable.

show 5 replies
Terr_today at 9:08 AM

See also: RAID levels that use one disk for parity. Three disks is simplest, but technically you can do more if you trust that only one will go bad at a time.

A few months ago, I had a rare occasion of trying to explain them to a relative who had just bought a fancy NAS and wanted help setting it up.

nsteeltoday at 8:52 AM

Also to cheaply (area) create multi-port RAMs.

show 1 reply