public void save() { PassPhraseEncryptionUtility ppeu = new PassPhraseEncryptionUtility(this.pp); try { byte[] encryptedBytes = ppeu.encrypt(toByteArray()); write(encryptedBytes); } catch (Exception e) { e.printStackTrace(); } }
/** * Load existing Binder object from a file. * * @param fileName, passPhrase * @return */ public static Binder getInstance(String fileName, String passPhrase) throws FileNotFoundException, BinderInstantiationException { PassPhraseEncryptionUtility ppeu = new PassPhraseEncryptionUtility(passPhrase); Binder b = null; try { byte[] buffer = getBytesFromFile(fileName); b = load(ppeu.decrypt(buffer)); b.pp = passPhrase; } catch (FileNotFoundException fe) { System.out.println("File " + fileName + " not found! Use createNewInstance() instead."); throw fe; } catch (Exception e) { throw new BinderInstantiationException("Error loading or creating Binder.", e); } return b; }