A while back I worked on an embedded system where we had some data that had to be encrypted.
The hardware was very limited, talking about an 8bit processor, so a proper encryption algorithm
was a no-no. Luckily, the security constraints weren’t too hight, and some basic obfuscation of the
data would do. For that I revisited the good old XOR encryption/hashing, adding a few personal touches to it.
The code above should speak for itself: It is a basic byte-wise XOR with the encryption key, plus an addition
to a “magic” constant that reduces the occurrence of the value 0 in the output, toped with a bit rotation,
with rotation amount defined by the caller as the last byte in the key vector.
It worked very well for the application and was pretty fast and low power consuming. I think it is actually a
pretty neat way to obfuscate data, specially with the bit rotation, which makes harder for a hacker to break the “encryption”.