duthientan.mmanm.com.Main.java Source code

Java tutorial

Introduction

Here is the source code for duthientan.mmanm.com.Main.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package duthientan.mmanm.com;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.DigestInputStream;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import org.apache.commons.codec.binary.Hex;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.cookie.Cookie;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;

/**
 *
 * @author DuThienTan
 */
public class Main extends javax.swing.JFrame {

    public CipherP cipherJV;
    public List<String> filePath = new ArrayList<>();
    public String key = "";
    public boolean isRSA = false;
    public String username = "";
    public String password = "";
    public String fileUploadPath = "";
    public String name = "";
    public String id = "";
    public String token = "";
    public boolean isLogin = false;
    String md5FIle1;
    String md5File2;

    /**
     * Creates new form Main
     */
    public Main() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelContainer = new javax.swing.JPanel();
        panelMenu = new javax.swing.JPanel();
        bntLogin = new javax.swing.JButton();
        bntHome = new javax.swing.JButton();
        bntDes = new javax.swing.JButton();
        bntRsa = new javax.swing.JButton();
        bntAes = new javax.swing.JButton();
        bntLogout = new javax.swing.JButton();
        bntUpload = new javax.swing.JButton();
        panelBody = new javax.swing.JPanel();
        panelLogin = new javax.swing.JPanel();
        labelLogo = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        textPassword = new javax.swing.JTextField();
        textUserName = new javax.swing.JTextField();
        bntLoginServer = new javax.swing.JButton();
        panelHome = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textLinkFile = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        labelNameHome = new javax.swing.JLabel();
        panelCipher = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        Encrypt = new javax.swing.JButton();
        JLKey = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        JLFILEPATH = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        BntOpenFile = new javax.swing.JButton();
        Decrypt = new javax.swing.JButton();
        progressBarCipher = new javax.swing.JProgressBar();
        jLabel9 = new javax.swing.JLabel();
        JLMD5 = new javax.swing.JLabel();
        BntOpenKey = new javax.swing.JButton();
        BntGenerationKey = new javax.swing.JButton();
        panelUpload = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        labelUserName = new javax.swing.JLabel();
        jProgressBar1 = new javax.swing.JProgressBar();
        btnOpenFileUp = new javax.swing.JButton();
        btnUploadFile = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        labelFileUpload = new javax.swing.JLabel();
        panelMD5 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        labelFIle1 = new javax.swing.JLabel();
        labelFile2 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        probarMD5 = new javax.swing.JProgressBar();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        panelContainer.setBackground(new java.awt.Color(0, 0, 0));

        panelMenu.setBackground(new java.awt.Color(0, 0, 0));

        bntLogin.setText("Login");
        bntLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntLoginActionPerformed(evt);
            }
        });

        bntHome.setText("Home");
        bntHome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntHomeActionPerformed(evt);
            }
        });

        bntDes.setText("DES");
        bntDes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntDesActionPerformed(evt);
            }
        });

        bntRsa.setText("RSA");
        bntRsa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntRsaActionPerformed(evt);
            }
        });

        bntAes.setText("AES");
        bntAes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntAesActionPerformed(evt);
            }
        });

        bntLogout.setText("MD5");
        bntLogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntLogoutActionPerformed(evt);
            }
        });

        bntUpload.setText("Upload");
        bntUpload.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntUploadActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelMenuLayout = new javax.swing.GroupLayout(panelMenu);
        panelMenu.setLayout(panelMenuLayout);
        panelMenuLayout.setHorizontalGroup(panelMenuLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelMenuLayout.createSequentialGroup().addContainerGap()
                        .addGroup(panelMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(bntLogin, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(bntHome, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(bntDes, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(bntRsa, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(bntAes, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(bntLogout, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                                .addComponent(bntUpload, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap()));
        panelMenuLayout.setVerticalGroup(panelMenuLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelMenuLayout.createSequentialGroup().addContainerGap().addComponent(bntLogin)
                        .addGap(18, 18, 18).addComponent(bntHome).addGap(18, 18, 18).addComponent(bntDes)
                        .addGap(18, 18, 18).addComponent(bntRsa).addGap(18, 18, 18).addComponent(bntAes)
                        .addGap(18, 18, 18).addComponent(bntUpload).addGap(18, 18, 18).addComponent(bntLogout)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        panelBody.setLayout(new java.awt.CardLayout());

        labelLogo.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\DuThienTan\\Documents\\NetBeansProjects\\nodeAuth\\img\\logo.png")); // NOI18N

        jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel2.setText("UserName");

        jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel3.setText("Password");

        bntLoginServer.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        bntLoginServer.setText("Login");
        bntLoginServer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntLoginServerActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelLoginLayout = new javax.swing.GroupLayout(panelLogin);
        panelLogin.setLayout(panelLoginLayout);
        panelLoginLayout.setHorizontalGroup(panelLoginLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelLoginLayout.createSequentialGroup().addGap(26, 26, 26)
                        .addGroup(panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3).addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(panelLoginLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(textUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 213,
                                        Short.MAX_VALUE)
                                .addComponent(textPassword))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(panelLoginLayout.createSequentialGroup().addGap(142, 142, 142).addComponent(labelLogo)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLoginLayout.createSequentialGroup()
                        .addContainerGap(133, Short.MAX_VALUE).addComponent(bntLoginServer,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(113, 113, 113)));
        panelLoginLayout.setVerticalGroup(panelLoginLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelLoginLayout.createSequentialGroup().addGap(42, 42, 42).addComponent(labelLogo)
                        .addGap(80, 80, 80)
                        .addGroup(panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel2).addComponent(textUserName,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(51, 51, 51)
                        .addGroup(panelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3).addComponent(textPassword,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(82, 82, 82).addComponent(bntLoginServer).addContainerGap(184, Short.MAX_VALUE)));

        panelBody.add(panelLogin, "card2");

        jLabel7.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\DuThienTan\\Documents\\NetBeansProjects\\nodeAuth\\img\\logo.png")); // NOI18N

        jLabel11.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel11.setText("UserName");

        textLinkFile.setColumns(20);
        textLinkFile.setRows(5);
        jScrollPane1.setViewportView(textLinkFile);

        jButton1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jButton1.setText("Get Link");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        labelNameHome.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N

        javax.swing.GroupLayout panelHomeLayout = new javax.swing.GroupLayout(panelHome);
        panelHome.setLayout(panelHomeLayout);
        panelHomeLayout.setHorizontalGroup(panelHomeLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        panelHomeLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(jLabel7)
                                .addGap(179, 179, 179))
                .addGroup(panelHomeLayout.createSequentialGroup().addContainerGap()
                        .addGroup(panelHomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane1)
                                .addGroup(panelHomeLayout.createSequentialGroup().addComponent(jLabel11)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(labelNameHome, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addContainerGap())
                .addGroup(panelHomeLayout.createSequentialGroup().addGap(165, 165, 165).addComponent(jButton1)
                        .addContainerGap(157, Short.MAX_VALUE)));
        panelHomeLayout
                .setVerticalGroup(panelHomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panelHomeLayout.createSequentialGroup().addGap(49, 49, 49).addComponent(jLabel7)
                                .addGap(51, 51, 51)
                                .addGroup(panelHomeLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(labelNameHome, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 238,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton1).addContainerGap(112, Short.MAX_VALUE)));

        panelBody.add(panelHome, "card2");

        jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel4.setText("FILE");

        Encrypt.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        Encrypt.setText("Encrypt");
        Encrypt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EncryptActionPerformed(evt);
            }
        });

        JLKey.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
        JLKey.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        jLabel6.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel6.setText("MD5");

        JLFILEPATH.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
        JLFILEPATH.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        jLabel8.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\DuThienTan\\Documents\\NetBeansProjects\\nodeAuth\\img\\logo.png")); // NOI18N

        BntOpenFile.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        BntOpenFile.setText("Open");
        BntOpenFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BntOpenFileActionPerformed(evt);
            }
        });

        Decrypt.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        Decrypt.setText("Decrypt");
        Decrypt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DecryptActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel9.setText("KEY");

        JLMD5.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
        JLMD5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        BntOpenKey.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        BntOpenKey.setText("Open");
        BntOpenKey.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BntOpenKeyActionPerformed(evt);
            }
        });

        BntGenerationKey.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        BntGenerationKey.setText("Generation Key");
        BntGenerationKey.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BntGenerationKeyActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelCipherLayout = new javax.swing.GroupLayout(panelCipher);
        panelCipher.setLayout(panelCipherLayout);
        panelCipherLayout.setHorizontalGroup(panelCipherLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelCipherLayout.createSequentialGroup().addContainerGap().addGroup(panelCipherLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panelCipherLayout.createSequentialGroup()
                                .addComponent(progressBarCipher, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addContainerGap())
                        .addGroup(panelCipherLayout.createSequentialGroup()
                                .addGroup(panelCipherLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelCipherLayout
                                                .createSequentialGroup().addComponent(jLabel9).addGap(2, 2, 2)
                                                .addComponent(JLKey, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addGroup(panelCipherLayout.createSequentialGroup().addComponent(jLabel4)
                                                .addGap(4, 4, 4).addComponent(JLFILEPATH,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(panelCipherLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(BntOpenFile)
                                        .addComponent(BntOpenKey, javax.swing.GroupLayout.Alignment.TRAILING))
                                .addContainerGap())
                        .addGroup(panelCipherLayout.createSequentialGroup().addGap(33, 33, 33).addComponent(Encrypt)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 137,
                                        Short.MAX_VALUE)
                                .addComponent(Decrypt).addGap(43, 43, 43))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                panelCipherLayout.createSequentialGroup().addComponent(jLabel6).addGap(2, 2, 2)
                                        .addComponent(JLMD5, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGap(14, 14, 14))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                panelCipherLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                        .addComponent(jLabel8).addGap(175, 175, 175))))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        panelCipherLayout.createSequentialGroup()
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(BntGenerationKey).addGap(132, 132, 132)));
        panelCipherLayout.setVerticalGroup(panelCipherLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelCipherLayout.createSequentialGroup().addContainerGap().addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelCipherLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(JLFILEPATH, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(BntOpenFile))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelCipherLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(BntOpenKey).addComponent(JLKey,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 37,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelCipherLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(panelCipherLayout.createSequentialGroup()
                                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 234, Short.MAX_VALUE))
                                .addComponent(JLMD5, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BntGenerationKey)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(progressBarCipher, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(panelCipherLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(Encrypt).addComponent(Decrypt))
                        .addContainerGap()));

        panelBody.add(panelCipher, "card2");

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel1.setText("UserName");

        jLabel5.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\DuThienTan\\Documents\\NetBeansProjects\\nodeAuth\\img\\logo.png")); // NOI18N

        labelUserName.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N

        btnOpenFileUp.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        btnOpenFileUp.setText("Open");
        btnOpenFileUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOpenFileUpActionPerformed(evt);
            }
        });

        btnUploadFile.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        btnUploadFile.setText("Upload");
        btnUploadFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUploadFileActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel10.setText("FileUpload");

        labelFileUpload.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N

        javax.swing.GroupLayout panelUploadLayout = new javax.swing.GroupLayout(panelUpload);
        panelUpload.setLayout(panelUploadLayout);
        panelUploadLayout.setHorizontalGroup(panelUploadLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelUploadLayout.createSequentialGroup().addGroup(panelUploadLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panelUploadLayout.createSequentialGroup().addGroup(panelUploadLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(panelUploadLayout.createSequentialGroup().addGap(177, 177, 177)
                                        .addComponent(jLabel5))
                                .addGroup(panelUploadLayout.createSequentialGroup().addGap(40, 40, 40).addComponent(
                                        jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 386,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(0, 0, Short.MAX_VALUE))
                        .addGroup(panelUploadLayout.createSequentialGroup().addContainerGap()
                                .addGroup(panelUploadLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(panelUploadLayout.createSequentialGroup().addComponent(jLabel10)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(labelFileUpload,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 205,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(btnOpenFileUp))
                                        .addGroup(panelUploadLayout.createSequentialGroup().addComponent(jLabel1)
                                                .addGap(34, 34, 34).addComponent(labelUserName,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                        .addContainerGap())
                .addGroup(panelUploadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                        javax.swing.GroupLayout.Alignment.TRAILING,
                        panelUploadLayout.createSequentialGroup().addContainerGap(158, Short.MAX_VALUE)
                                .addComponent(btnUploadFile).addGap(179, 179, 179))));
        panelUploadLayout.setVerticalGroup(panelUploadLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelUploadLayout.createSequentialGroup().addGap(64, 64, 64).addComponent(jLabel5)
                        .addGap(77, 77, 77)
                        .addGroup(panelUploadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1).addComponent(labelUserName,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 37,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(25, 25, 25)
                        .addGroup(panelUploadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btnOpenFileUp).addComponent(jLabel10).addComponent(labelFileUpload,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 37,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 154, Short.MAX_VALUE)
                        .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(113, 113, 113))
                .addGroup(panelUploadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                        javax.swing.GroupLayout.Alignment.TRAILING,
                        panelUploadLayout.createSequentialGroup().addContainerGap(579, Short.MAX_VALUE)
                                .addComponent(btnUploadFile).addGap(27, 27, 27))));

        panelBody.add(panelUpload, "card2");

        jLabel12.setIcon(new javax.swing.ImageIcon(
                "C:\\Users\\DuThienTan\\Documents\\NetBeansProjects\\nodeAuth\\img\\logo.png")); // NOI18N

        jLabel13.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel13.setText("File 1");

        jLabel14.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel14.setText("File 2");

        jButton2.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jButton2.setText("Open");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        labelFIle1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N

        labelFile2.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N

        jButton3.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jButton3.setText("Open");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jButton4.setText("Check MD5");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelMD5Layout = new javax.swing.GroupLayout(panelMD5);
        panelMD5.setLayout(panelMD5Layout);
        panelMD5Layout.setHorizontalGroup(panelMD5Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelMD5Layout.createSequentialGroup()
                        .addGroup(panelMD5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(probarMD5, javax.swing.GroupLayout.PREFERRED_SIZE, 387,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(panelMD5Layout.createSequentialGroup().addContainerGap()
                                        .addGroup(panelMD5Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel13).addComponent(jLabel14))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(panelMD5Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(labelFIle1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        249, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(labelFile2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        249, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(panelMD5Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jButton2).addComponent(jButton3))))
                        .addGap(0, 9, Short.MAX_VALUE))
                .addGroup(panelMD5Layout.createSequentialGroup()
                        .addGroup(panelMD5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(panelMD5Layout.createSequentialGroup().addGap(133, 133, 133)
                                        .addComponent(jButton4))
                                .addGroup(panelMD5Layout.createSequentialGroup().addGap(155, 155, 155)
                                        .addComponent(jLabel12)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        panelMD5Layout.setVerticalGroup(panelMD5Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelMD5Layout.createSequentialGroup().addGap(33, 33, 33).addComponent(jLabel12)
                        .addGap(59, 59, 59)
                        .addGroup(panelMD5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel13)
                                .addComponent(labelFIle1, javax.swing.GroupLayout.PREFERRED_SIZE, 42,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 42,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(31, 31, 31)
                        .addGroup(panelMD5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(labelFile2, javax.swing.GroupLayout.PREFERRED_SIZE, 42,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel14).addComponent(jButton3,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 42,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 197, Short.MAX_VALUE)
                        .addComponent(probarMD5, javax.swing.GroupLayout.PREFERRED_SIZE, 41,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18).addComponent(jButton4).addGap(32, 32, 32)));

        panelBody.add(panelMD5, "card2");

        javax.swing.GroupLayout panelContainerLayout = new javax.swing.GroupLayout(panelContainer);
        panelContainer.setLayout(panelContainerLayout);
        panelContainerLayout.setHorizontalGroup(panelContainerLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelContainerLayout.createSequentialGroup().addContainerGap()
                        .addComponent(panelMenu, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panelBody, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));
        panelContainerLayout.setVerticalGroup(
                panelContainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                        javax.swing.GroupLayout.Alignment.TRAILING,
                        panelContainerLayout.createSequentialGroup().addContainerGap()
                                .addGroup(panelContainerLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(panelBody, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(panelMenu, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addContainerGap()));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(panelContainer, javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                panelContainer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bntLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntLoginActionPerformed
        // TODO add your handling code here:
        if (!isLogin) {
            startSrceenCipher(panelLogin);
        }
    }//GEN-LAST:event_bntLoginActionPerformed

    private void bntHomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntHomeActionPerformed
        // TODO add your handling code here:
        if (isLogin) {
            startSrceenCipher(panelHome);
        }
    }//GEN-LAST:event_bntHomeActionPerformed

    private void bntDesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntDesActionPerformed
        // TODO add your handling code here:
        isRSA = false;
        clearSrceenCipher();
        BntGenerationKey.setVisible(false);
        startSrceenCipher(panelCipher);
        cipherJV = new CipherDES();
    }//GEN-LAST:event_bntDesActionPerformed

    private void bntRsaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntRsaActionPerformed
        // TODO add your handling code here:
        isRSA = true;
        clearSrceenCipher();
        BntGenerationKey.setVisible(true);
        startSrceenCipher(panelCipher);
        cipherJV = new CipherRSA();
    }//GEN-LAST:event_bntRsaActionPerformed

    private void bntAesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntAesActionPerformed
        // TODO add your handling code here:
        isRSA = false;
        clearSrceenCipher();
        BntGenerationKey.setVisible(false);
        startSrceenCipher(panelCipher);
        cipherJV = new CipherAES();
    }//GEN-LAST:event_bntAesActionPerformed

    private void bntLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntLogoutActionPerformed
        // TODO add your handling code here:
        panelBody.removeAll();
        panelBody.add(panelMD5);
        panelBody.repaint();
        panelBody.validate();
    }//GEN-LAST:event_bntLogoutActionPerformed

    private void bntUploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntUploadActionPerformed
        // TODO add your handling code here:
        clearSrceenCipher();
        startSrceenCipher(panelUpload);
        labelUserName.setText(name);
    }//GEN-LAST:event_bntUploadActionPerformed

    private void BntOpenFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BntOpenFileActionPerformed
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setMultiSelectionEnabled(true);
        int returnValue = fileChooser.showOpenDialog(null);

        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File[] selectedFiles = fileChooser.getSelectedFiles();
            JLFILEPATH.setText(selectedFiles.length + " files is selected");
            JLMD5.setText("Caculating");
            filePath = new ArrayList<>();
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        String mD5 = "";
                        for (File f : selectedFiles) {
                            filePath.add(f.getPath());
                            FileInputStream fis = new FileInputStream(f);
                            mD5 += f.getName() + " : " + org.apache.commons.codec.digest.DigestUtils.md5Hex(fis)
                                    + "<br>";
                            fis.close();
                        }
                        JLMD5.setText("<html>" + mD5 + "</html>");
                    } catch (IOException ex) {
                        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }).start();
        }
    }//GEN-LAST:event_BntOpenFileActionPerformed

    private void BntOpenKeyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BntOpenKeyActionPerformed
        JFileChooser fileChooser = new JFileChooser();
        int returnValue = fileChooser.showOpenDialog(null);
        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File selectedFile = fileChooser.getSelectedFile();
            if (isRSA) {
                key = selectedFile.getParent();
                JLKey.setText(selectedFile.getName());
                JFrame frame = new JFrame("ERROR");
                JOptionPane.showMessageDialog(frame, key);
                return;
            }
            if (selectedFile.getName().contains(".txt")) {
                JLKey.setText(selectedFile.getName());
                try {
                    BufferedReader br = new BufferedReader(new FileReader(selectedFile.getPath()));
                    StringBuilder sb = new StringBuilder();
                    String line = br.readLine();

                    while (line != null) {
                        sb.append(line);
                        sb.append(System.lineSeparator());
                        line = br.readLine();
                    }
                    key = sb.toString();
                    JFrame frame = new JFrame("ERROR");
                    JOptionPane.showMessageDialog(frame, key);
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                }
            } else {
                JFrame frame = new JFrame("ERROR");
                JOptionPane.showMessageDialog(frame, "Please Choice File TXT");
            }
        }
    }//GEN-LAST:event_BntOpenKeyActionPerformed

    private void EncryptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EncryptActionPerformed
        // TODO add your handling code here:
        if (!key.equals("") && filePath.size() != 0) {
            progressBarCipher.setIndeterminate(true);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (String file : filePath) {
                        cipherJV.setKey(key);
                        cipherJV.encrypt(file);
                    }
                    clearSrceenCipher();
                    progressBarCipher.setIndeterminate(false);
                    JFrame frame = new JFrame("COMPLETED");
                    JOptionPane.showMessageDialog(frame, "Final Encrypt File");
                }
            }).start();

        } else {
            JFrame frame = new JFrame("ERROR");
            JOptionPane.showMessageDialog(frame, "Please Choice File Key And File To Cipher");
        }
    }//GEN-LAST:event_EncryptActionPerformed

    private void DecryptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DecryptActionPerformed
        // TODO add your handling code here:
        if (!key.equals("") && filePath.size() != 0) {
            progressBarCipher.setIndeterminate(true);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (String file : filePath) {
                        cipherJV.setKey(key);
                        cipherJV.decrypt(file);
                    }
                    clearSrceenCipher();
                    progressBarCipher.setIndeterminate(false);
                    JFrame frame = new JFrame("COMPLETED");
                    JOptionPane.showMessageDialog(frame, "Final Decrypt File");
                }
            }).start();
        } else {
            JFrame frame = new JFrame("ERROR");
            JOptionPane.showMessageDialog(frame, "Please Choice File Key And File To Cipher");
        }
    }//GEN-LAST:event_DecryptActionPerformed

    private void BntGenerationKeyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BntGenerationKeyActionPerformed
        // TODO add your handling code here:
        if (filePath.size() != 0) {

            progressBarCipher.setIndeterminate(true);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        Path path = Paths.get(filePath.get(0));
                        String srcParent = path.getParent().toString();
                        final KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
                        keyGen.initialize(2048);
                        final KeyPair key = keyGen.generateKeyPair();
                        File privateKeyFile = new File(srcParent + "/private.key");
                        File publicKeyFile = new File(srcParent + "/public.key");
                        publicKeyFile.createNewFile();
                        publicKeyFile.createNewFile();
                        ObjectOutputStream publicKeyOS = new ObjectOutputStream(
                                new FileOutputStream(publicKeyFile));
                        publicKeyOS.writeObject(key.getPublic());
                        publicKeyOS.close();
                        ObjectOutputStream privateKeyOS = new ObjectOutputStream(
                                new FileOutputStream(privateKeyFile));
                        privateKeyOS.writeObject(key.getPrivate());
                        privateKeyOS.close();
                        progressBarCipher.setIndeterminate(false);
                        JFrame frame = new JFrame("COMPLETED");
                        JOptionPane.showMessageDialog(frame, "Greneration Key File Completed");
                    } catch (IOException ex) {
                        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (NoSuchAlgorithmException ex) {
                        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }).start();

        } else {
            JFrame frame = new JFrame("ERROR");
            JOptionPane.showMessageDialog(frame, "Please Choice File To Cipher Before Greneration Key");
        }
    }//GEN-LAST:event_BntGenerationKeyActionPerformed

    private void bntLoginServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntLoginServerActionPerformed
        // TODO add your handling code here:
        username = textUserName.getText();
        password = textPassword.getText();
        if (username.equals("") && password.equals("")) {
            try {
                HttpClient httpclient = HttpClients.createDefault();
                HttpPost httppost = new HttpPost("http://localhost:4000/api/login");
                List<NameValuePair> params = new ArrayList<NameValuePair>(2);
                params.add(new BasicNameValuePair("username", "meoxauxa.kiss"));
                params.add(new BasicNameValuePair("password", "0963243736"));
                httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
                HttpResponse response = httpclient.execute(httppost);
                JSONObject obj = new JSONObject(EntityUtils.toString(response.getEntity()));
                isLogin = true;
                id = obj.getString("id");
                name = obj.getString("name");
                token = obj.getString("token");
                JFrame frame = new JFrame("Login Success");
                JOptionPane.showMessageDialog(frame, "Hello " + name);
            } catch (UnsupportedEncodingException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            JFrame frame = new JFrame("Login Failed");
            JOptionPane.showMessageDialog(frame, "UserName Or Password Is Empty");
        }
    }//GEN-LAST:event_bntLoginServerActionPerformed

    private void btnOpenFileUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOpenFileUpActionPerformed
        // TODO add your handling code here:
        JFileChooser fileChooser = new JFileChooser();

        int returnValue = fileChooser.showOpenDialog(null);

        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File selectedFile = fileChooser.getSelectedFile();
            fileUploadPath = selectedFile.getPath();
            labelFileUpload.setText(selectedFile.getName());
        }
    }//GEN-LAST:event_btnOpenFileUpActionPerformed

    private void btnUploadFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUploadFileActionPerformed
        // TODO add your handling code here:
        if (!fileUploadPath.equals("")) {
            progressBarCipher.setIndeterminate(true);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        HttpClient httpclient = new DefaultHttpClient();
                        httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
                                HttpVersion.HTTP_1_1);
                        HttpPost httppost = new HttpPost("http://localhost:4000/api/upload");
                        File file = new File(fileUploadPath);
                        MultipartEntity mpEntity = new MultipartEntity();
                        ContentBody cbFile = new FileBody(file);
                        mpEntity.addPart("files", cbFile);
                        httppost.addHeader("id", id);
                        httppost.addHeader("x-access-token", token);
                        httppost.setEntity(mpEntity);
                        HttpResponse response = httpclient.execute(httppost);
                        HttpEntity resEntity = response.getEntity();
                        progressBarCipher.setIndeterminate(false);
                        JFrame frame = new JFrame("Upload Completed");
                        JOptionPane.showMessageDialog(frame, "File Uploaded");
                    } catch (IOException ex) {
                        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }).start();
        } else {
            JFrame frame = new JFrame("File not Found");
            JOptionPane.showMessageDialog(frame, "Plase Choice File Upload");
        }
    }//GEN-LAST:event_btnUploadFileActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        try {
            HttpClient httpclient = new DefaultHttpClient();
            httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
            HttpGet httpGet = new HttpGet("http://localhost:4000/api/store");
            httpGet.setHeader("id", id);
            httpGet.addHeader("x-access-token", token);
            HttpResponse response = httpclient.execute(httpGet);
            JSONObject obj = new JSONObject(EntityUtils.toString(response.getEntity()));
            //System.out.println(EntityUtils.toString(response.getEntity()));
            JSONArray jsonArr = obj.getJSONArray("arr");
            String result = "";
            for (int i = 0; i < jsonArr.length(); i++) {
                result += "http://localhost:4000/" + jsonArr.get(i).toString() + "\n";
            }
            textLinkFile.setText(result);
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        JFileChooser fileChooser = new JFileChooser();
        int returnValue = fileChooser.showOpenDialog(null);

        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File selectedFiles = fileChooser.getSelectedFile();
            md5File2 = selectedFiles.getPath();
            labelFile2.setText(md5File2);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        probarMD5.setIndeterminate(true);
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    FileInputStream fis1 = new FileInputStream(md5FIle1);
                    String f1 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis1);
                    FileInputStream fis2 = new FileInputStream(md5File2);
                    String f2 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis2);
                    if (f1.equals(f2)) {
                        JFrame frame = new JFrame("2 File Is Match");
                        JOptionPane.showMessageDialog(frame, "Matched");
                    } else {
                        JFrame frame = new JFrame("2 File Is Not Match");
                        JOptionPane.showMessageDialog(frame, "Not Match");
                    }
                    probarMD5.setIndeterminate(false);
                    fis1.close();
                    fis2.close();
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }).start();
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        JFileChooser fileChooser = new JFileChooser();
        int returnValue = fileChooser.showOpenDialog(null);

        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File selectedFiles = fileChooser.getSelectedFile();
            md5FIle1 = selectedFiles.getPath();
            labelFIle1.setText(md5FIle1);
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void clearSrceenCipher() {
        JLFILEPATH.setText("");
        JLKey.setText("");
        JLMD5.setText("");
    }

    private void startSrceenCipher(javax.swing.JPanel srceen) {
        panelBody.removeAll();
        panelBody.add(srceen);
        panelBody.repaint();
        panelBody.validate();
        filePath = new ArrayList<>();
        key = "";

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BntGenerationKey;
    private javax.swing.JButton BntOpenFile;
    private javax.swing.JButton BntOpenKey;
    private javax.swing.JButton Decrypt;
    private javax.swing.JButton Encrypt;
    private javax.swing.JLabel JLFILEPATH;
    private javax.swing.JLabel JLKey;
    private javax.swing.JLabel JLMD5;
    private javax.swing.JButton bntAes;
    private javax.swing.JButton bntDes;
    private javax.swing.JButton bntHome;
    private javax.swing.JButton bntLogin;
    private javax.swing.JButton bntLoginServer;
    private javax.swing.JButton bntLogout;
    private javax.swing.JButton bntRsa;
    private javax.swing.JButton bntUpload;
    private javax.swing.JButton btnOpenFileUp;
    private javax.swing.JButton btnUploadFile;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel labelFIle1;
    private javax.swing.JLabel labelFile2;
    private javax.swing.JLabel labelFileUpload;
    private javax.swing.JLabel labelLogo;
    private javax.swing.JLabel labelNameHome;
    private javax.swing.JLabel labelUserName;
    private javax.swing.JPanel panelBody;
    private javax.swing.JPanel panelCipher;
    private javax.swing.JPanel panelContainer;
    private javax.swing.JPanel panelHome;
    private javax.swing.JPanel panelLogin;
    private javax.swing.JPanel panelMD5;
    private javax.swing.JPanel panelMenu;
    private javax.swing.JPanel panelUpload;
    private javax.swing.JProgressBar probarMD5;
    private javax.swing.JProgressBar progressBarCipher;
    private javax.swing.JTextArea textLinkFile;
    private javax.swing.JTextField textPassword;
    private javax.swing.JTextField textUserName;
    // End of variables declaration//GEN-END:variables
}