Asymmetric Encryption Program in JAVA

First thing I want to start this with a question of what exactly is Encryption? In cryptography(It is the study of secure communications techniques that allow only the sender and intended recipient of a message to view its contents.), encryption is the process of encoding information. This process converts the original representation of the information, known as plaintext, into an alternative form known as ciphertext.

Now the two main kinds of encryption are symmetric encryption and asymmetric encryption.

So we are going to discuss asymmetric encryption here. Asymmetric encryption is also known as public key encryption. Asymmetric Encryption uses two distinct, yet related keys. One key, the Public Key, is used for encryption and the other, the Private Key, is for decryption. As implied in the name, the Private Key is intended to be private so that only the authenticated recipient can decrypt the message. However as Asymmetric Encryption incorporates two separate keys, the process is slowed down considerably. You’re using Asymmetric Encryption without even realizing it. When you visit any HTTPS website/webpage, your browser establishes Asymmetrically encrypted connection with that website. Your browser automatically derives the public key of the SSL/TLS certificate installed on the website. Click the padlock you see in front of our URL, and go to certificate details.

Now that we have a theoretical understanding of asymmetric encryption I shall give an overview to my java program. In this code we are actually going to be using ASCII table(characters from 32-126) to generate a key automatically. We will be having 6 cases of prompt in the console one being default value("Invalid!"). We want our program to

  • generate new keys
  • access those generated keys
  • Encrypt it
  • Decrypt it
  • Quit the menu. We need to make sure that generated key and the decrypted key are shuffled, so that the keys would be unorthodox. In this way you can encrypt any message and send it to others along with a private key to decrypt it. This link would guide you to my java code of asymmetric encryption program.