public void encryptFile(PlainDocument doc){
        try {
                BufferedReader br = new BufferedReader(new FileReader(doc.getId() + ".txt"));
                StringBuilder sb = new StringBuilder();

                File file = new File(doc.getId() + "-cipher.txt");

                // if file doesnt exists, then create it
                if (!file.exists()) {
                        file.createNewFile();
                }
                
                FileWriter fw = new FileWriter(file.getAbsoluteFile());
                BufferedWriter bw = new BufferedWriter(fw);

                String line = br.readLine();

                while (line != null) {
                        sb.append(line);
                        sb.append("\n");
                        line = br.readLine();

                }
                
                String everything = sb.toString();
                everything = encrypt(everything);
                
                bw.write(everything);
                bw.close();
                br.close();
                System.out.println("Archivo Encriptado");
                
            } 
            catch (FileNotFoundException e) {
                    e.printStackTrace();
            } 
            catch (Exception e) {
                    e.printStackTrace();
            }
    }