| 159 | } |
| 160 | |
| 161 | @Override |
| 162 | public void actionPerformed(ActionEvent e) { |
| 163 | if (e.getActionCommand().equals("Encrypt")) { |
| 164 | String masterPassword = masterPasswordField.getText(); |
| 165 | String password = passwordField.getText(); |
| 166 | String encryptedPassword = encrypt(masterPassword, password); |
| 167 | if (encryptedPassword != null) { |
| 168 | encryptedPasswordField.setText(encryptedPassword); |
| 169 | encryptedPasswordfileField.setText("Encrypted! Check file."); |
| 170 | } |
| 171 | } else if (e.getActionCommand().equals("Decrypt")) { |
| 172 | String masterPassword = masterPasswordField.getText(); |
| 173 | String encryptedPassword = encryptedPasswordField.getText(); |
| 174 | String decryptedPassword = decrypt(masterPassword, encryptedPassword); |
| 175 | if (decryptedPassword != null) { |
| 176 | decryptedPasswordField.setText(decryptedPassword); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | public static void main(String[] args) { |
| 182 | SwingUtilities.invokeLater(PasswordManagerGUI::new); |