How to create project RSA Cryptography with JAVA in 3 Steps: Step 2 Create Process Logic Algorithm Encrypt Decrypt

Ia Kurnia
2 min readDec 23, 2021
Process Encrypt Decrypt

Hi Guys, this article continues the article part1 about summary RSA algorithm and creating UI for testing your project. After creating UI for testing, then next we create how to process encrypt and decrypt with algorithm RSA on a file.

Then what’s a step for creating this algorithm. Let’s do the steps.

Step 1 create Generator Key

  • Make a class with the name generatoyKey, and you must create a method for generating a random key.
  • To make it easier, save generate a key on a file.

Step 2 create Public Key and Private Key

  • After making generate a key, next, you create public key and private key
  • And to make it easier, save public key or private key on a file.

Step 3 create proses Encrypt generate Key

  • After steps 1 and step 2 have been made. Then next you must encrypt generate key pervious made to ensure safety
  • And to make it easier, save the encryption on a file and save it on the directory you want

Step 4 create proses Decrypt generate Key

  • After step 3 has been made that is for encryption for generate key, you don’t forget to create also decrypt on generate key for reading file the encryption has been previous made.

Step 5 create proses Encrypt on a file

  • After making public and private keys, and then we just make a process algorithm for encrypting with the use of a public key that has been made.
  • To make it easier, you create a new class that works for encryption. with a name class for example AlgoritmRsa

Step 6 create proses Decrypt on a file

  • After that function encryption, you just create function decrypt from result file encrypt the previous made.

So as not to waste time, let’s go for creating code step by step. follow the source code below.

Yey great jobs, finally we have been processed the algorithm RSA for encrypting and decrypting on a file. Note, for now, we tested with the static file. In the next article is the last article, we will test with a file real directory path and combination User Interface testing has been made for Step 1. See you in the next article!

--

--

Ia Kurnia

I love new technology and follow the advancements in the field. We Can Do It If We Want To Learn and Try.