Encryption
Click here to use.

Home made XOR encryption

Their are many free open source encryption programs out on the net. I was interested in how some of them worked and decided to write my own text encryption program using php. Because of this, anyone can access the page which encrypts/decrypts messages. This means there is no software to install, and anyone who has internet access on any device can use it.

How it works

The basic idea of XOR encryption is simple and involves a message and a key. A secret key is applied to a message with the XOR formula, the result is a scrambled message that can only be retrieved by having both the key and the scrambled message.

The method I use to encrypt messages is quite simple, the first step involves converting the ASCII text into binary. Once it is in binary I generate number between [0-1] using a pseudo random number generator. This process is repeated 64 times to generate a 64 bit binary "key". The 64 bit key is converted to HEX format to make it easier to read when it is displayed onto the screen. Now that I have a message in binary and a 64 bit key in binary all I have to do is perform an XOR calculation on them and the result is the encrypted message.

The XOR function takes 2 binary numbers and produces a result based on the following rules. 0 XOR 0 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1, 1 XOR 1 = 0. For example, if my secret message was "1001" and my key was "1101" Then the encrypted message would be "0100" I could then send the encoded number 0100 to someone, everyone knows that 0100 is the result of the Message XOR Key, but since they do not have the key they can not figure out what the message is.

A key of different lengths can be used (32, 64, 128, 256 etc). Depending on the length of the message the key will be reused over again. For example, if a 64 bit key was used, the first bit of the key would be applied to the first bit of the message untill all 64 bits of the key were used on the first 64 bits of the message. Then on the 65th bit of the message the key would be reused from the begining again. By encrypting 64 or more bits with a key at a time it is difficult to analyze the encrypted message to try to find patterns since more than one word is encrypted with the key

The final encrypted message is converted to HEX(A-F, 0-9) to make it shorter and easier to read. Decrption of a message simply works backwards to convert the hex to binary and decrypt the text back to front then converts the result into ASCII so the original message appears.