AES with Java

Welcome everybody!

Today I want to show a new Java created by myself. It is useful in the case that you want to protect your messages from possible eavesdropper. If you like stories of espionage, the names of Snowden and Wikileaks will not sound new to you. In both the cases the protection or discovery of a secret were the main point of the debate.

When we want to protect our message we are doing “cryptography”.

In general, when we want to protect our message we are doing “cryptography”. At the contrary, if we want to discovery a message (without a password) we are doing “cryptanalysis”. With the java program that you can download from the next link, we are doing “cryptography”.

AES-128, AES-192, and AES-256 in one program

With this program you will be able to encrypt and decrypt text files (not photos, programs or videos) with one of the most secure method of encryption: AES-256 (or alternatively AES-128 or AES-192).

EncDecAES

To create this Java program I used the original paper that the authors, Joan Daemen and Vincent Rijmen, used to propose Rijndael, better known as AES. At this link you can find the original pdf.

For the creation of this program I found two interesting problems: the first one was of mathematical nature. To work with a field with 256 elements, called GF(256), is not simple and required some notion of not trivial algebra. Especially if you don’t understand that he chosen “x” in GF(256) is not a primitive element, but “x+1” it is. Luckily my PhD came to help me, and the creation of a the encryption systems was not really hard for myself. The use of Sage (Python with mathematical steroids) was fundamental to create efficiently this mathematics part.  If you don’t understand the problem, don’t worry! And be happy!

This is a good friend for a programmer that wants to use mathematics.

The second problem was with the implementation of AES. By having a Chinese wife and being myself Italian, I should use symbols as “我” or “é”. For this reason I should say goodbye to my old friend UTF-8 and say welcome to UTF-16 and its UNICODE world. It was not really challenging, but still interesting.

Give a try! But be careful! If you encrypt a file and you delete the original one (DON’T DO IT), then you can recover your original document only if you own the password. I can’t accept any responsibility or liability for damages arising from the misuse of this program.

Your sincerely,
Stefano Martin

 

Share This:

Project Euler

One famous website to test your own ability to code is Project Euler.net. This website offers over 500 different challenges that can be solved only by the use of some programming language.

The programming language of my choice is Java. Thus with courage and ambition I started quickly to write and compile lines and lines of codes.

Since I just began, the quantity of my solved exercises (25) is not actually exciting. But it permits me to obtain the first level of Euler Project.net that equivals to be in the 14.75% of people that was able to solve at least 25 problems.

I want to add one thing: the exercise usually are very specific, by requiring an exact value. For example problem 7 asks: “What is the 10001st prime number?”
My program solves instead: “What is the n-th prime number?” where n is a positive integer. I like to have more general answers.

If you are curious you can find my Bitbucket repository here: click me!

Oh! About the repositories! At the bottom of my webpage you can find now a small bucket. That one will permit you to find my repositories on Bitbucket.

Best,
Stefano Martin

Share This:

Fractals with Java

Hello everybody!

Today I created a new program in Java to create self similar sets. This are a type of fractals generated by rotations, translations and shrinking. However pictures are worth thousands of words. Let me to give some examples!

Frac4
Spirals
Frac3
Likes leaves
Pythagoras tree
Pythagoras tree
Frac2
Rains

The slider on the left are used to create your fractal on the right. Here the meaning of any sliders:

  • S indicates in how many way we want to repeat our fractals. For example for the Pythagoras tree we use two ways.
  • Times indicates how many times we want to repeat our pictures.

The user needs to be careful on using the “Times” slider because the number of points will increase exponentially.
In general, by using a little of math, we know that we have (S+1)^Times squares, so 4(S+1)^Times points. For example, for S = 2, Times = 10, our picture will represents 3^10 little squares.

  • For any function S we need to assign a rotation in degrees (with “Grade”), a shrinking in percentage (with “Size”) and a translation (in x with “X axis” and in y with “Y axis”).
    For example if we have Grade=45, Size=75, X axis=100, Y axis=-50, it means that we rotate our square of 45°, our new picture will be 75% the original one, and it will moved on the right of 100 pixels and on the bottom of 50 pixels.

You can download this small Java programs from here: Link v1.0 (9 KB) (old version with black fractals)

Link v1.1 (10 KB)
+ Added at the bottom a save button to save your fractals in .png files
+ Now the fractals are in red
+ Correct small mistakes

Note: To open a jar file in Windows, you must have the Java Runtime Environment installed.

Best,
Stefano Martin

Share This: