/** * The ActionListener implementation * * @param event the event. */ public void actionPerformed(ActionEvent event) { String searchText = textField.getText().trim(); if (searchText.equals("") && !saveAs.isSelected() && (fileLength > 10000000)) { textPane.setText("Blank search text is not allowed for large IdTables."); } else { File outputFile = null; if (saveAs.isSelected()) { outputFile = chooser.getSelectedFile(); if (outputFile != null) { String name = outputFile.getName(); int k = name.lastIndexOf("."); if (k != -1) name = name.substring(0, k); name += ".txt"; File parent = outputFile.getAbsoluteFile().getParentFile(); outputFile = new File(parent, name); chooser.setSelectedFile(outputFile); } if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) System.exit(0); outputFile = chooser.getSelectedFile(); } textPane.setText(""); Searcher searcher = new Searcher(searchText, event.getSource().equals(searchPHI), outputFile); searcher.start(); } }
void initCipher() { try { b64Decoder = new BASE64Decoder(); b64Encoder = new BASE64Encoder(); Provider sunJce = new com.sun.crypto.provider.SunJCE(); Security.addProvider(sunJce); byte[] raw = b64Decoder.decodeBuffer(key); SecretKeySpec skeySpec = new SecretKeySpec(raw, "Blowfish"); deCipher = Cipher.getInstance("Blowfish"); deCipher.init(Cipher.DECRYPT_MODE, skeySpec); enCipher = Cipher.getInstance("Blowfish"); enCipher.init(Cipher.ENCRYPT_MODE, skeySpec); } catch (Exception ex) { textPane.setText("Unable to create the cipher"); } }