Simple XOR encryption decryption in Javascript
I like cryptography from the pen and paper era. Think about all those “analogue” secret messages of WWII. Modern cryptography is all done by computers, and unaccessible to pen and paper, but simple systems can be easily implemented.
One of such systems is XORing the text message with a passphrase byte by byte and produce some ciphertext. If the passphrase is at least as long as the input message, and random, then you’ll get a secure ciphertext.
I’ve created a page that allows you to encrypt and decrypt messages. In this case the output text is a sequence of numbers separated by whitespace. To decipher the numbers you input the list of numbers as input and the same passphrase.
If you want an offline version, copy the source HTML to a local HTML file and open in your browser.
This might be useful for sending emails, or to use in printed media. This requires the recipient to know the password and the XOR process. They can either code an app to reverse the process or they can use the webpage above, or have a local copy.
Is it secure? Don’t trust my word for it. It is a toy using XOR. Security depends on many things like length and randomness of passphrase, never reusing the passphrase, etc… But at least for obfuscation, this can be very interesting.
It is worth noticing that any agency can store these messages until they find your passphrase. Then, in the future, they’ll be able to read all your past messages and incriminate you for what you said.
Think about it. Play with it. Don’t trust it. Don’t trust me. Read the code. Understand what it does. Implement your own version.