The main project of this chapter is a tiny, simple (not to say primitive) encryption/decryption module written entirely in Assembly. Since the topic of this chapter is interfacing Assembly modules and modules written in high-level languages, we will not delve into cryptography principles, but we will rather concentrate on the portability and interoperability of our code while using a slightly modified XOR algorithm. The idea behind the algorithm is to receive an array of bytes and do the following:
- Take a byte and rotate it a certain number of bits to the left (the counter is randomly generated at compile time).
- XOR the result with the 1-byte key (randomly generated at compile time as well).
- Write the byte back to the array.
- If there are more bytes to encrypt, go to step 1; otherwise break out of the loop.
The following screenshot is an example output of the algorithm...