List of Topics:
Location Research Breakthrough Possible @S-Logix pro@slogix.in

Office Address

Social List

How to Encrypt and Decrypt data using RSA in Java ?

Encrypt and Decrypt data using RSA in Java

Condition for Encrypt and Decrypt data using RSA in Java

  • Description:
    RSA encryption and decryption use a pair of keys , a public key for encryption and a private key for decryption. The encryption process involves using the recipient’s public key to transform plaintext into ciphertext. The recipient can then use their private key to decrypt the ciphertext back into the original plaintext. RSA relies on the mathematical difficulty of factoring large prime numbers, making it a secure method for data transmission. The public key is shared openly, while the private key is kept confidential. RSA encryption typically operates on small chunks of data, and for larger datasets, symmetric encryption algorithms like AES are often used in combination with RSA.
    The RSA algorithm provides confidentiality by ensuring that only the holder of the private key can decrypt the data that was encrypted with the corresponding public key. The strength of RSA encryption increases with larger key sizes, typically ranging from 1024 to 4096 bits, where larger key sizes offer stronger security but require more computational resources.
Sample Code
  • Encryption:
    package rsa_draganddrop;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.security.KeyFactory;
    import java.security.KeyPair;
    import java.security.KeyPairGenerator;
    import java.security.PrivateKey;
    import java.security.PublicKey;
    import java.security.spec.X509EncodedKeySpec;
    import java.util.Base64;
    import javax.crypto.Cipher;
    import javax.swing.JFileChooser;
    import javax.swing.JOptionPane;

    public class RSA_Client extends javax.swing.JFrame {

    private PublicKey publicKey;
    private KeyPair keyPair;

    private static final String PUBLIC_KEY_FILE = "publicKey.key";

    public RSA_Client() {
    initComponents();

    try {
    KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
    keyPairGenerator.initialize(2048);
    keyPair = keyPairGenerator.generateKeyPair();
    PublicKey publicKey = keyPair.getPublic();
    PrivateKey privateKey = keyPair.getPrivate();

    savePublicKey(publicKey, PUBLIC_KEY_FILE);
    setTitle("Client");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    } catch (Exception e) {
    System.out.println(e.getMessage());
    }
    }

    @SuppressWarnings("unchecked")
    private void initComponents() {
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jTextField1 = new javax.swing.JTextField();
    jButton1 = new javax.swing.JButton();
    jTextField2 = new javax.swing.JTextField();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jLabel3 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jButton4 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jLabel1.setText("Input File:");
    jLabel2.setText("Output File:");
    jButton1.setText("Choose File");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });
    jButton2.setText("Choose File");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton2ActionPerformed(evt);
    }
    });
    jButton3.setText("RSA_ENCRYPT");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton3ActionPerformed(evt);
    }
    });
    jLabel3.setText("RSA_ALGORITHM_ENCRYPTION");
    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jScrollPane1.setViewportView(jTextArea1);
    jButton4.setText("Public Key");
    jButton4.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton4ActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    .addContainerGap(68, Short.MAX_VALUE)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jButton3)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(132, 132, 132))
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(136, 136, 136))))
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 490, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(37, 37, 37))
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    .addComponent(jButton4)
    .addGap(211, 211, 211))))
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(56, 56, 56)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jLabel1)
    .addComponent(jLabel2))
    .addGap(41, 41, 41)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
    .addComponent(jTextField1)
    .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)))
    .addGroup(layout.createSequentialGroup()
    .addGap(150, 150, 150)
    .addComponent(jLabel3)))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jLabel3)
    .addGap(35, 35, 35)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(jLabel1)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(28, 28, 28)
    .addComponent(jButton1)
    .addGap(50, 50, 50)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel2)
    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(29, 29, 29)
    .addComponent(jButton2)
    .addGap(40, 40, 40)
    .addComponent(jButton3)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(18, 18, 18)
    .addComponent(jButton4)
    .addContainerGap(55, Short.MAX_VALUE))
    );
    pack();
    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    JFileChooser fileChooser = new JFileChooser();
    int result = fileChooser.showOpenDialog(this);
    if (result == JFileChooser.APPROVE_OPTION) {
    File selectedFile = fileChooser.getSelectedFile();
    jTextField1.setText(selectedFile.getAbsolutePath());
    }
    }
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    JFileChooser fileChooser = new JFileChooser();
    int result = fileChooser.showOpenDialog(this);
    if (result == JFileChooser.APPROVE_OPTION) {
    File selectedFile = fileChooser.getSelectedFile();
    jTextField2.setText(selectedFile.getAbsolutePath());
    }
    }
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
    try {
    String inputFilePath = jTextField1.getText();
    String outputFilePath = jTextField2.getText();
    byte[] inputBytes = readFile(inputFilePath);
    byte[] encryptedBytes = encrypt(inputBytes);
    writeFile(outputFilePath, encryptedBytes);
    JOptionPane.showMessageDialog(this, "File encrypted successfully.");
    } catch (Exception ex) {
    JOptionPane.showMessageDialog(this, "Error encrypting file: " + ex.getMessage());
    }
    }
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
    display();
    }
    private byte[] readFile(String filePath) throws IOException {
    File file = new File(filePath);
    FileInputStream fis = new FileInputStream(file);
    byte[] data = new byte[(int) file.length()];
    fis.read(data);
    fis.close();
    return data;
    }
    private void writeFile(String filePath, byte[] data) throws IOException {
    FileOutputStream fos = new FileOutputStream(filePath);
    fos.write(data);
    fos.close();
    }
    private byte[] encrypt(byte[] inputBytes) throws Exception {
    Cipher cipher = Cipher.getInstance("RSA");
    cipher.init(Cipher.ENCRYPT_MODE, readPublicKeyFromFile());
    return cipher.doFinal(inputBytes);
    }
    private PublicKey readPublicKeyFromFile() throws Exception {
    FileInputStream fis = new FileInputStream(PUBLIC_KEY_FILE);
    byte[] encodedPublicKey = new byte[fis.available()];
    fis.read(encodedPublicKey);
    fis.close();
    X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encodedPublicKey);
    KeyFactory keyFactory = KeyFactory.getInstance("RSA");
    return keyFactory.generatePublic(keySpec);
    }
    private static void savePublicKey(PublicKey publicKey, String PUBLIC_KEY_FILE) throws Exception {
    byte[] publicKeyBytes = publicKey.getEncoded();
    try (FileOutputStream fos = new FileOutputStream(PUBLIC_KEY_FILE)) {
    fos.write(publicKeyBytes);
    }
    }
    public static void main(String args[]) throws Exception {
    java.awt.EventQueue.invokeLater(() -> {
    new RSA_Client().setVisible(true);
    });
    }
    private void display() {
    try {
    byte[] publicKeyBytes = readPublicKeyFromFile().getEncoded();
    String res = Base64.getEncoder().encodeToString(publicKeyBytes);
    jTextArea1.setText(res);
    } catch (Exception e) {
    System.out.println(e.getMessage());
    }
    }
    }
  • Decryption:
    package rsa_draganddrop;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.security.KeyFactory;
    import java.security.KeyPair;
    import java.security.KeyPairGenerator;
    import java.security.PrivateKey;
    import java.security.PublicKey;
    import java.security.Security;
    import java.security.spec.PKCS8EncodedKeySpec;
    import java.util.Base64;
    import javax.crypto.Cipher;
    import javax.swing.JFileChooser;
    import javax.swing.JOptionPane;
    import org.bouncycastle.jce.provider.BouncyCastleProvider;
    public class RSA_Server extends javax.swing.JFrame {
    private PrivateKey privateKey;
    private int result;
    public static final String PUBLIC_KEY_FILE = "publicKey.key";
    public static final String PRIVATE_KEY_FILE = "privateKey.key";
    public RSA_Server() {
    initComponents();
    setTitle("Server");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
    @SuppressWarnings("unchecked")
    //
    private void initComponents() {
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jTextField1 = new javax.swing.JTextField();
    jButton1 = new javax.swing.JButton();
    jTextField2 = new javax.swing.JTextField();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jLabel3 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jButton4 = new javax.swing.JButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jLabel1.setText("File Path");
    jLabel2.setText("File Path");
    jTextField1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jTextField1ActionPerformed(evt);
    }
    });
    jButton1.setText("Choose File");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });
    jTextField2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jTextField2ActionPerformed(evt);
    }
    });
    jButton2.setText("Choose File");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton2ActionPerformed(evt);
    }
    });
    jButton3.setText("RSA_DECRYPT");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton3ActionPerformed(evt);
    }
    });
    jLabel3.setText("RSA_ ALGORITHM_DECRYPTION");
    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jScrollPane1.setViewportView(jTextArea1);
    jButton4.setText("Private Key");
    jButton4.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton4ActionPerformed(evt);
    }
    });
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(72, 72, 72)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jLabel1)
    .addComponent(jLabel2))
    .addGap(46, 46, 46)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
    .addComponent(jTextField1)
    .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)))
    .addGroup(layout.createSequentialGroup()
    .addGap(232, 232, 232)
    .addComponent(jButton1))
    .addGroup(layout.createSequentialGroup()
    .addGap(120, 120, 120)
    .addComponent(jLabel3))
    .addGroup(layout.createSequentialGroup()
    .addGap(229, 229, 229)
    .addComponent(jButton2))
    .addGroup(layout.createSequentialGroup()
    .addGap(186, 186, 186)
    .addComponent(jButton3)))
    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
    .addGap(23, 23, 23)
    .addComponent(jButton4)
    .addGap(0, 268, Short.MAX_VALUE)))
    .addGroup(layout.createSequentialGroup()
    .addGap(23, 23, 23)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 555, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addContainerGap(70, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(31, 31, 31)
    .addComponent(jLabel3)
    .addGap(38, 38, 38)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel1)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(29, 29, 29)
    .addComponent(jButton1)
    .addGap(45, 45, 45)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel2)
    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(18, 18, 18)
    .addComponent(jButton2)
    .addGap(28, 28, 28)
    .addComponent(jButton3)
    .addGap(37, 37, 37)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
    .addComponent(jButton4)
    .addGap(73, 73, 73))
    );
    pack();
    }//

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    JFileChooser fileChooser = new JFileChooser();
    int result = fileChooser.showOpenDialog(this);
    if (result == JFileChooser.APPROVE_OPTION) {
    File selectedFile = fileChooser.getSelectedFile();
    jTextField1.setText(selectedFile.getAbsolutePath());
    }
    }
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    JFileChooser fileChooser = new JFileChooser();
    int result = fileChooser.showOpenDialog(this);
    if (result == JFileChooser.APPROVE_OPTION) {
    File selectedFile = fileChooser.getSelectedFile();
    jTextField2.setText(selectedFile.getAbsolutePath());
    }
    }
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
    try {
    String inputFilePath = jTextField1.getText();
    String outputFilePath = jTextField2.getText();
    byte[] inputBytes = readFile(inputFilePath);
    byte[] decryptedBytes = decrypt(inputBytes);
    writeFile(outputFilePath, decryptedBytes);
    JOptionPane.showMessageDialog(this, "File decrypted successfully.");
    } catch (Exception ex) {
    JOptionPane.showMessageDialog(this, "Error decrypting file: " + ex.getMessage());
    }
    }
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
    display();
    }
    private byte[] readFile(String filePath) throws IOException {
    File file = new File(filePath);
    FileInputStream fis = new FileInputStream(file);
    byte[] data = new byte[(int) file.length()];
    fis.read(data);
    fis.close();
    return data;
    }
    private void writeFile(String filePath, byte[] data) throws IOException {
    FileOutputStream fos = new FileOutputStream(filePath);
    fos.write(data);
    fos.close();
    }
    private byte[] decrypt(byte[] encryptedBytes) throws Exception {
    Cipher cipher = Cipher.getInstance("RSA");
    cipher.init(Cipher.DECRYPT_MODE, readPrivateKeyFromFile());
    return cipher.doFinal(encryptedBytes);
    }
    private PrivateKey readPrivateKeyFromFile() throws Exception {
    FileInputStream fis = new FileInputStream(PRIVATE_KEY_FILE);
    byte[] encodedPrivateKey = new byte[fis.available()];
    fis.read(encodedPrivateKey);
    fis.close();
    PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedPrivateKey);
    KeyFactory keyFactory = KeyFactory.getInstance("RSA");
    return keyFactory.generatePrivate(keySpec);
    }
    private static void savePublicKey(PublicKey publicKey, String filePath) throws Exception {
    byte[] publicKeyBytes = publicKey.getEncoded();
    try (FileOutputStream fos = new FileOutputStream(filePath)) {
    fos.write(publicKeyBytes);
    }
    }
    private static void savePrivateKey(PrivateKey privateKey, String filePath) throws Exception {
    byte[] privateKeyBytes = privateKey.getEncoded();
    try (FileOutputStream fos = new FileOutputStream(filePath)) {
    fos.write(privateKeyBytes);
    }
    }
    private void display() {
    try {
    byte[] publicKeyBytes = readPrivateKeyFromFile().getEncoded();
    String res = Base64.getEncoder().encodeToString(publicKeyBytes);
    jTextArea1.setText(res);
    } catch (Exception e) {
    System.out.println(e.getMessage());
    }
    }
    public static void main(String args[]) throws Exception {
    KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
    keyPairGenerator.initialize(2048);
    KeyPair keyPair = keyPairGenerator.generateKeyPair();
    PublicKey publicKey = keyPair.getPublic();
    PrivateKey privateKey = keyPair.getPrivate();
    savePublicKey(publicKey, PUBLIC_KEY_FILE);
    savePrivateKey(privateKey, PRIVATE_KEY_FILE);
    Security.addProvider(new BouncyCastleProvider());
    java.awt.EventQueue.invokeLater(() -> {
    new RSA_Server().setVisible(true);
    });
    }
    // Variables declaration - do not modify
    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 jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration
Step 1
  • To start the encryption process, select the input file path after setting up the RSA encryption GUI.
  • Encrypt and Decrypt data using RSA1
  • Encrypt and Decrypt data using RSA2
Step 2
  • The choosen file location is indicated by the selected file path that shows up in the text field.
  • Encrypt and Decrypt data using RSA3
Step 3
  • Select the path of the 'Encrypt.txt' file to begin the encryption process.
  • Encrypt and Decrypt data using RSA4
Step 4
  • The path of the 'Encrypt.txt' file has been selected for encryption.
  • Encrypt and Decrypt data using RSA5
Step 5
  • The files Encrypt.txt and input.txt are chosen. When the Encrypt button is clicked, encryption is successfully finished.
  • Encrypt and Decrypt data using RSA6
Step 6
  • To start the decryption process, select the input file path after setting up the RSA decryption GUI.
  • Encrypt and Decrypt data using RSA7
  • Encrypt and Decrypt data using RSA8
Step 7
  • The chosen file location is indicated by the selected file path that shows up in the text field.
  • Encrypt and Decrypt data using RSA9
Step 8
  • Select the path of the 'Decrypt.txt' file to begin the decryption process.
  • Encrypt and Decrypt data using RSA10
Step 9
  • The path of the 'Decrypt.txt' file has been selected for decryption.
  • Encrypt and Decrypt data using RSA11
Step 10
  • The files Encrypt.txt and Decrypt.txt are chosen. When the Decrypt button is clicked, decryption is successfully finished.
  • Encrypt and Decrypt data using RSA12
Step 11
  • RSA uses a public key for encryption and a private key for decryption. The public key shares with anyone, while the private key stays secure.
  • Encrypt and Decrypt data using RSA13
  • Encrypt and Decrypt data using RSA14
Step 12
  • Encryption applies to the input text file, with the result saved in the encrypt text file. Decryption restores the original content from the decrypt text file.
  • Encrypt and Decrypt data using RSA15
  • Encrypt and Decrypt data using RSA16
  • Encrypt and Decrypt data using RSA17
  • Public Key File :
    Encrypt and Decrypt data using RSA18
  • Private Key File :
    Encrypt and Decrypt data using RSA19