A one-time-pad is a method for encrypting a message using a key. First, all the characters in both the key and message are converted to numbers. Then each character is subtracted from it's matching character in the key text. The result is converted back into a character. Technically there is no way to crack the code as the same cipher could decrypt to any message given the right key. However the problem is, you need some way to communicate the key to the recipient in the first place hence why it's not widely used. More info.
Very simply, the encrypt function uses a for loop to process each letter in the Plaintext box. First the letter is converted to it's ASCII decimal number code, then it is added to the ASCII code of the character at the same position in the key string (If the key is shorter than the plaintext a 'loop' variable is incremented so that the key is repeated as many times as necessary, I suspect there is a more elegant way of achieving this..). The sum of the two characters is converted back into an ASCII character and displayed at that position in the ciphertext. If the sum of the characters falls outside the printable range, a simple equation adds the difference to the bottom of the range so that is it printable.
The reverse happens when in Decrypt mode i.e. the ASCII code is subtracted and any difference below the range is subtracted from the top of the range. And that's it really!
Click the 'Latest Version' link above
Enter your message in the first (plaintext) box, enter key text in the second box, your encrypted message will appear in the third. You can copy and paste sections of books, articles, news sites, reddit, anything with text in it for the key. It should be as long as the message but it will loop round as needed if it's not. Any changes you make to the plaintext or key boxes should cause the output to update automagically
You can press the 'Encrypt' heading at the top to change mode to decrypt. This reverses the order of the boxes and means that any changes to the Ciphertext or Key boxes will change the output in the Plaintext box. This is useful if you want to nest encryption or use it as a puzzle/riddle e.g. If I drink, I die. If I eat, I am fine. What am I?
PL\PíO_PUêoY\ÚVg_ÓaUWæ]YPJc@ïRc\VF`õ~£À¼·×Ê¾ÈÑÒ½ÞÐÐ ¼ÑÕÖ´ÓÁåÐÊ¦§óîÿ)-#,2%CVapødOjae\óVSreæXi3ó9[a`ôZ``icXî`aeJï^y!ç;dømYpñ^Xgî[p _^j%WPW,øKR\eù`fî[p?æ,2B ôÿ¯¢£ÉÍÇÝÍÇÜÆÏáÔÚÔÚÚàÔÕ×ÌÙ¨¢£¦