I am currently trying to implement a very fast and simple encryption algorithm in Lua for the purpose of using it with ComputerCraft.
The main problem is that bitwise operations in Lua (5.2 at least) are very slow and the implementation ComputerCraft can only handle 32 bit integers in their bit-library, so implementing standard algorithms isn't easy.
On the other hand this is only a game and encryption is merely used to keep others from simply controlling your devices or reading your messages. There is no critical data associated with this, so the encryption can be very weak.
I currently implemented a combination of XOR and random in the following form (pseudo-code):
random.seed( hash(key) ) -- 32 bit seed
for i = 1 to str.length do
result[i] = str[i] XOR random.nextByte()
end
The good thing about this is that it only uses a single bit-operation and is guaranteed to never exceed 32 bit. Also this is very fast.
Aside from external problems like random entropy, what is an approximate time someone would need to decrypt this using a standard desktop PC? (sophisticated guess is ok, I just want to get an idea)
And if this is just too weak, is there any other algorithm that is more secure, but fast and can be implemented with a minimum amount of bit operations fitting in 32-bit?