Encryption – Do you need to secure your files?

Security, anonymity​ and privacy are topics you hear a lot about these days. When the news is filled with how terrorists used encryption to mask their evil activities one might ask do we really need it? I would say we absolutely do. It would be easy to make a case for government agencies, banks and even medical services to have access to this type of technology, but I’d even say we as individuals need to use it.​ The Bureau of ​Justice Stastics reported that in 2014​ there were 17.6 million US residents that experienced identity theft.​ On average it costs victims about $1,500 in lost finances and that’s not counting lost hours and stress caused by cleaning up the mess. Most of your personal files don’t need encrypted but you should protect your sensitive data. Things like financial, medical, website passwords, etc should be secure.​​

I’ve spent some time learning the ins and outs of encryption. There’s still much I don’t know, but I do feel I have a good grip on how many of these technologies work.​ I want to use the rest of this article to explain a little about encryption an application I’ve created called Xcipher and how it works.

The two main types of encryption are public and private key. Public key is what we often use when we connect to a secure website. It uses very large prime numbers to create a key that is used to encrypt data in a file. Primes are significant because they take a very long time to factor.​ For example​​ I can take two large prime numbers and multiply them together in seconds, but if I take the result and try to find the two numbers that created it, that would take a long time and for very large primes it could take thousands of years to crack.

Xcipher uses private key encryption which doesn’t use prime numbers at all. Private key encryption is similar to writing your password or padlock combination on a sheet of paper and storing it away till later. The file cannot be unencrypted without the password and it’s kept secret from others.

The Xcipher application will read a byte from the input file create an encrypted byte based upon a character in the password, and then write that byte to the output file….and continue through the entire file.

A byte is 8 bits, and the first read of the file would contain data like this: {01101001 010010101 10100001}.​​ ​After the data is read​ a “mask” of the same length (8 bits) must be created. This mask is basically a random number from 0 – 255. It is used to flip the bits using an Xor operator. Java has a function that returns a random number.  Something really helpful about this function and what makes this application possible is the fact that you can seed the random function with a starting point and it will then return a sequence of numbers that are always the same. If I create a million random numbers the second run with the same seed will create the exact same million numbers.

Let’s say our password is “apple”. It has already read in byte: 01101001 and the first character of the password is a lower case ‘a’. If you use its integer value you get the number 97. We then generate 97 random numbers, toss them to the side, and then use the 98th, which will be an integer between 0 and 255, and that will be our mask. We throw the first numbers away to add complexity to the algorithm making it near impossible to calculate the mask that is returned. If you dont’ have the password that is used to create the mask and the starting point (seed) for the random number you cannot determine the mask. Without it you cannot recreate the original byte.

There are 256 possible number between 0 – 255, and that is important because that is also the largest number possible with a byte. The binary number 11111111 is equal to the decimal number 255. So the random number that is chosen is always the size of one byte….our mask is a random number the size of a byte.

Now lets say the 98th number was 133 which is the binary number 10000101. So now we have:
01101001 – original byte
10000101 – mask 
The Exclusive Or (know as an Xor operator) will compare the two bytes bit for bit.  You remember those truth tables you learned in college, well here’s the one for Xor:

  • 1 Xor 1 = 0
  • 1 Xor 0 = 1
  • 0 Xor 1 = 1
  • 0 Xor 0 = 0.

Let’s do the calculation:
01101001 – original byte
10000101 – mask
____________________________XOR
11101100 – encrypted byte

Xcipher screen shot:

enc2

 

 

 

 

 

 

 

So how does the decryption work? Well, when you run the encrypted file back through the same program, it will read in the encrypted byte, and when Xor’d with the same mask, it will produce the original byte. So the Xor acts like a switch that will flip the bits back to the original, and java will produce the exact random numbers each time.

Just because bad people use a good technology doesn’t make that technology bad. Encryption is a powerful tool that makes our online communication safe and secure and we should not fear it. If you’re interested in the application just message me and I’ll give you a copy.

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

*