|
|
|
|
|
by simias
3420 days ago
|
|
I have a similar memory from my early days of coding. I was implementing a toy rc4 cipher. One of the steps in the ciphers involves swapping entries in an arrays of 256 elements. I thought "hey, I'm a 1337 coder, I'm going to use the xor trick". Except it doesn't work if you're trying to swap something with itself. If you do "a[i] ^= a[j]" and i == j then you're just clearing the entry. Taught me the valuable lesson that I shouldn't try to be a smartass while writing code and the importance of unit tests. |
|
[0] http://www.underhanded-c.org/_page_id_16.html