try {
keySize = Integer.parseInt(txtKeySize.getText().trim());
} catch (Exception e2) {
}
Encrypter encrypter = null;
try {
if (radAsymmetricCipher.isSelected()) {
encrypter = AsymmetricEncrypterFactory.getInstance().buildEncrypter(
algorithm, keySize);
} else if (isPBEAlgorithm(algorithm)) {
// Password-based encryption
String password = new String(jPasswordField1.getPassword());
encrypter = BPEEncrypterFactory.getInstance().buildEncrypter(
algorithm, keySize, password);
} else {
encrypter = SymmetricEncrypterFactory.getInstance().buildEncrypter(
algorithm, keySize);
}
String message = encrypter.getKeySizeSuggestion();
if (message != null) {
showMessage(message);
return;
}
if (encrypter instanceof AsymmetricEncrypter) {
((AsymmetricEncrypter) encrypter).setKeyFile2(txtPublicKey.getText());
}
String inputFile = txtInputFile.getText();
String outputFile = txtOutputFile.getText();
File keyFile = new File(txtKeyFile.getText());
if (textEncryption.isSelected()) {
if (source == jButton1) {
encryprtString(plainTextArea, cipherTextArea, keyFile, encrypter);
} else {
decryprtString(cipherTextArea, plainTextArea, keyFile, encrypter);
}
} else {
if (source == btnEncrypt) {
encrypter.encrypt(inputFile, outputFile, keyFile);
} else {
encrypter.decrypt(inputFile, outputFile, keyFile);
}
}
if (source == btnEncrypt || source == jButton1) {
message = "Encrypt successfully";