Saturday, April 8, 2017

Create an encryption decryption Software




This Encryption is the process of translating plain text data (plain text) into something that
appears to be random and meaningless (cipher text).Decryption is the process of converting cipher text back to plain text. There are two types of encryption methods as symmetric encryption and asymmetric encryption.

Here is the encryption decryption software that i created   ----------->   http://bit.ly/2oZHj4E

In symmetric encryption, a symmetric key is used to encrypt and decrypt purposes. key is a secret like a password used to encrypt and decrypt information.



Symmetric encryption is an old encryption technique. The key which is used to encrypt and decrypt data is known as the secret key. Secret key can be either a number, a word or a string which contains random letters.It is blended with the plain text of a message to change the content in a particular way. In order to decrypt the message, receiver also should know the secret key. DES, 3DES, AES are some of the symmetric encryption algorithms. The biggest challenge in symmetric encryption is that both sender and the receiver has to securely share the secret key before sending the message.



package com.javapapers.java.security;

import java.util.Base64;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class EncryptionDecryptionAES {
 static Cipher cipher;

 public static void main(String[] args) throws Exception {
  KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
  keyGenerator.init(128);
  SecretKey secretKey = keyGenerator.generateKey();
  cipher = Cipher.getInstance("AES");

  String plainText = "AES Symmetric Encryption Decryption";
  System.out.println("Plain Text Before Encryption: " + plainText);

  String encryptedText = encrypt(plainText, secretKey);
  System.out.println("Encrypted Text After Encryption: " + encryptedText);

  String decryptedText = decrypt(encryptedText, secretKey);
  System.out.println("Decrypted Text After Decryption: " + decryptedText);
 }

 public static String encrypt(String plainText, SecretKey secretKey)
   throws Exception {
  byte[] plainTextByte = plainText.getBytes();
  cipher.init(Cipher.ENCRYPT_MODE, secretKey);
  byte[] encryptedByte = cipher.doFinal(plainTextByte);
  Base64.Encoder encoder = Base64.getEncoder();
  String encryptedText = encoder.encodeToString(encryptedByte);
  return encryptedText;
 }

 public static String decrypt(String encryptedText, SecretKey secretKey)
   throws Exception {
  Base64.Decoder decoder = Base64.getDecoder();
  byte[] encryptedTextByte = decoder.decode(encryptedText);
  cipher.init(Cipher.DECRYPT_MODE, secretKey);
  byte[] decryptedByte = cipher.doFinal(encryptedTextByte);
  String decryptedText = new String(decryptedByte);
  return decryptedText;
 }
}


Asymmetric encryption is also known as the public key cryptography where two keys are used as public key and private key. Public key is available to anyone. Private key is only known by yourself. outsiders don’t know the private key.A message that is encrypted using a public key can only be decrypted using a private key, while also, a message encrypted using a private key can be decrypted using a public key.
When the message is encrypted by the sender’s private key, it can only be decypted by sender’s public key. Here , as the public key is publicly available, anyone who get to know the sender’s public key can read the message, which is integrity and availability is not preserved.
when the message is encrypted using receiver’s public key, then receiver’s private key is needed to decrypt the message. As the receiver’s private key is known only by the receiver, it can only decrypted by the receiver.
In order to use asymmetric encryption, we have to find a way of discover correct public keys. For that, we can use digital certificates in a client-server model communication. A certificate is a package of information that identifies a user and a server. It contains information such as an organization’s name, the organization that issued the certificate, the user’s email address and country, and users public key.
When a server and a client require a secure encrypted communication, they send a query over the network to the other party, which sends back a copy of the certificate. The other party’s public key can be extracted from the certificate. A certificate can also be used to uniquely identify the holder.

No comments:

Post a Comment

Get Unlimited Free Trials Using a "Real" Fake Credit Card Number

When I see the words "free trial," I know I'm probably going to have to whip out my credit card and enter in the number to ...