martes, 28 de agosto de 2012

One time pad

One Time Pad

Hi everyone, this is the homework of one time pad. Firstly one time pad is a concept  of cryptography, is a type of encryption algorithms by which the plain text is combined with a random key same length as the plain text and used only once. It was invented in 1917. If the key is truly random, never reused and, of course, is kept secret, it can be shown that the method of the one-time pad is unbreakable. 

So, for this homework i created a one time pad encryption using Python, i'll resume all my work in few steps. 

1 - I created the text files ("keys1.txt", and "keys2.txt")






These are all the keys generated(in both files: "keys1.txt", and "keys2.txt"). 10 different keys, but it doesn't matter because each message crypted and decrypted will generate different keys. The length of each key is 7  because this is the length of ASCII values (in binary).





2 - I requested to user for a string 




3 - Each character of the string gave by the user goes to the encrypt function.






4 - Then each character goes to the decrypt function





5 - Finally i printed out the binary value of the character, key used,  xor result, xor decrypted (using xor method again), ASCII value and the character decrypted.





Now, this is all my code...



Finally this is mi program running (The message is: its)


If you want to write more messages you must to type 1 (if you type 2, program will close), and new messages will be crypted with other new key.



Leave your comment if you have any doubt


Thank you

No hay comentarios:

Publicar un comentario