For this hw I have created a program that first reads a message from a file called "Message" then convert it to numbers, and then to binary.
Then I create a random key with the length of the binary string (that is saved in a file), and I apply XOR.
The result is encrypted message, now I created decrypt functions, and you can read the original message.
The code is all commented to understand him better.
I leave screenshot of several runs to see how it changes the encrypted message can fit the key.
Code:
Results:
Avoid ambiguos abbreviations like "hw" (could be homework or hardware :P). The point was to generate first a one time pad, that is, a collection of keys, and then make two replicas of the pad. Then, to encrypt, person A uses her pad, and to decrypt, person B uses his - or vice versa. You receive 4 pts for the exercise.
ResponderEliminar