Saturday, January 10, 2009

#SJEA - Simple Java Encryption Algorithm

Not long ago (around 2007), I wrote this very simple encryption algorithm to help out a friend with the master's degree in computing. After a while I realized this could turn out to be a great stand alone project.

It was collecting dust for quite some time (one year or so) and I've decided that I should work more on this and complete it as a accessible public package. So recently I've managed to tidy the source, make some examples, write the documentation and now its finished - SJEA (Simple Java Encryption Algorithm). I have to admit the name is a bit silly for the simple reason that the 'J' can be replaced very easily (with source porting) to 'C' as a 'Simple C Encryption Algorithm' SCEA or anything else to be honest.

Going back to cryptography studies was pure fun. Back in the day around y2000 I was reading a lot on the subject and this resulted a lot of drafts. I guess this project will be the first I release under GPL. Now back on the topic.
SJEA v1.0SJEA started when I was looking for an alternative solution (a completely custom algorithm) to all the pre-made libraries in JAVA, C etc. Having something for granted is cool, but making your own tools may give you some great satisfaction. The idea of the project was that the result are good (not that easy to hack/decrypt with conventional tools) but the source (roots of the algorithm) easy to understand by people who are new to this type of study. So I've decided to have a go with Block and XOR ciphers. I was dealing with such for quite a while, so it wasn't a problem to implement them into some sort of a starting template.

The XOR method (the method behind all the calculation) is quite simple to understand:
We have an input byte that we sum with a key (modifier) and then we have a result. But if we subtract the key from the end result we will get the original input byte.

where A-input, B-mod, C-sum for a single byte entry
A+B=C //encryption
C-B=A //decryption

In SJEA the 'ECB' (Electronic codebook) window method can be found since we use a user password as our key. The password is used as a first layer of encryption. A vector byte-array is also present as a second layer. This complicates things a little (not that much) since even if you know the key modifier layer you wouldn't know the value of the vector.

Here is the 2-layer encryption scheme:

      input: AAAAAAAAAAAAAAAAAAAAA + (sum)
     vector: 01234567890ABCDEF0123 + (sum)

The project can be aimed at the following audiences:
- students of computing
- future algorithm programmers
- people who a learning into cryptography

It may eventually grow into a lot bigger project with many different encryption examples.

And here is a brand new website hosted by

or the googlecode page: