I’m putting up the last cryptographic algorithm I implemented in Java. It’s the winner of AES contest, providing high security and good speed.

It is called Rijndael or more commonly AES. I wont bother you with details anymore. For any references wikipedia is your friend.

Here is the wikipedia article about it, and more helpful check out the external links for a complete description of the algorithm.

Apart from the others I talked about, AES uses pretty advanced mathematical operations in the Galois Field.

Sorry for the lack of comments in the source code I’m putting below, but functions names are pretty descriptive and you should be able to pick it up if you go through it having some AES description document at hand. Call me lazy…that’s the truth :)

I’ve also put together an Eclipse project including all algorithms I’ve discussed, with some test cases.

### Like this:

Like Loading...

wonderful!!!!

Thank You very much man!

Thanks for the AES algorithm. I need to back level some code to jdk 1.4 and it does not have the cipher which came in 1.6 (I believe). However when testing the decryption algorithm I did find a bug. It was dropping the last character of the decrypted byte array in the deletePadding() method. I corrected this by removing the -1 in the following line of code:

byte[] tmp = new byte[input.length - count - 1];

Thanks again!

No problem.

Thanks you pointed it out.

I’ll check and repair it when I’ll have time.

Excellent AES algorithm for compatibility with C code supplied by NXP for LPC1769

Really great – thank you very much!

Thanks :)

Helped me with a delayed-to-the-last-minute project.

Guyz, can any1 tell me how to run this AES implementation in eclipse……. cuz wen i tried to execute the code in eclipse it gave me an error sayin “selection does not contain a main type”

thnxx in advance:)

Hi,

There’s a full eclipse project uploaded. You can find it on the AES article.

It contains all algorithms along with some test cases.

Hope it helps.

yess, was of very much help…

wonderfull blog here..

thanx again :)

i just started to learn AES code.. i try to RUN the code in eclipse.. but it cannot RUN.. and there are error. what should i do..

the full eclipse project found on the AES post should run without error.

Search for the error you receive, in case the above is not working. I cannot help you without seeing the error.

Ok its working. It was my mistake. I have got the output. I try to change the Text clar but it will be error. Is it possible for me to change the input? One more question, where can i learn basic of AES Algorithm. I need to do study project with it. But actually i am zero about the AES. Thank You. I really appreciate your help, sir.

Text clar: CRIPTEAZA ASTA

Text criptat poligramic: ABCGIPE APSRWJ

Text anterior descifrat: CRIPTEAZA ASTA

im sorry, i need to ask some questions,

(1) What is actually String K stand for? Is it a KEY? Is it possible for me to change it?

(2) What is mean by “Text criptat” ? Is it a cipher text?

(3) Then lastly, actually i try to put another string then the criptat value is something like this:

Enter Text:

zakirin

Text clar: zakirin

Text criptat AES: ñµJ-ùì^“?ŸèUõ

Text decriptat AES: zakirin

——————

my question is, why criptat is not in numbering mode? Please help me to understand this. Thank You. I really need help in this encryption.

yes, k is the key.

text criptat is the encrypted text.

thanks for the info

thankyou so much…it really helped!!

Can you please tell me what additional steps do i have to add if i want to extend the the algorithm to 128-bits encryption?

As I recall, my example already uses 128 bits encryption – both bloc size and key size.

Perhaps you want to extend it to greater key lengths. The process stays almost the same, you’ll need to change some constants. Reading AES specs might help(try wikipedia).

can u plz explain this code :D :P ;)

Sry…there’s too much theory involved. Would be best if you follow the code along with official AES specification.

great codes. I want to know. How you develop the permutation array in code of polygram.

if you are referring to polygram substitution cipher, it a simple one. It substitutes block of characters(2 in my case) with another block. So I generate a matrix with all possible combinations of 2 chars, than mix it up with some permutation array. This can be anything. It just tells what indices will get permuted. Do this several times until the initial matrix looks random. Than taking 2 chars from plain text, substitute it with the chars found at column/row intersection of the substitution matrix.

Thank you for shared code. I copypasted it in my current project for j2me (yes i know it is obsolete) platform which has lack of any crypto api.

any suggestion what can i do to speed up AES encryption? tq

is there any limit of character for text input and key? i noticed that key cannot be lower than 3 character. why the key should be more than three character? is it because of 128 bit? tq

there is not limit on the input text. The key lenght is fixed – 128 bits for example or up to 256 for AES

ok thanks for the information and the codes

With the source code that have all classes listed, there is no Galois Field, if there is in what class should i find it. I found codes about it but written in C. Here is what i need to do:

Write a program that can serve as a four function calculator for carrying out the arithmetic operations (+, −, ×,and ÷) on the polynomials that belong to the finite field GF(28) using the irreducible polynomial m(x) = x8 + x4 + x3 + x + 1. When started, your script should place the user in an interactive mode and wait for the user to enter expressions for evaluation. Your script should prompt the user for three items:

1) a bitstring that would serve as the first operand;

2) another bitstring that would serve as the second operand; and, finally,

3) the operator to be used. The bits in each input bit pattern supplied by the user would stand for the respective polynomial coefficients. The program should output a bitstring that is the result of the operation.

Any Help will be greatly appreciated.