August 23, 2012

One time pad

Well this week I have to make a program using the one time pad method.

What I have to do?

  • First, I have to create x number of keys, this keys have to be binary numbers
  • Second, the program asks the user for a message to encrypt. This program writes the key that use and the cypher text in a file
  • Third, the program using another function opens the file with the cypher text and the key and decrypt the cypher text.
For this program I use the xor function to encrypt the message, so the program takes each value of the binary text and each value of the key and applies them the xor function

An example could be if the binary message is 0100101 and the key 0001101, the cypher text would be:

message: 0100101
key:        0001101
cypher:   0101000

Here is my program:
(Note: due to time I couldn't make the function to decrypt the message, I just only implement the function to encrypt the message)



Here are some images of the program running:

  • In this image we can see each character of the message being encrypted



  • This is the file where I have the keys:


  • Here is the file where I have the key and the cypher text




1 comment:

  1. Well, you get 2 points for what you managed to complete. Note that the key should be as long as the message. Repeating the key makes the system much more vulnerable.

    ReplyDelete