/**
  * @param key The best key for the
  * @param path
  */
 private void decryptFile(int key, String path) {
   try (BufferedReader br = Files.newBufferedReader(Paths.get(path));
       BufferedWriter bw = Files.newBufferedWriter(Paths.get(path + ".dec"))) {
     RailFence rf = new RailFence();
     String line;
     while ((line = br.readLine()) != null) {
       bw.write(rf.decrypt(line, key) + "\n");
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Example #2
0
  public void run() {
    RailFence rf = new RailFence();
    String plainText = rf.decrypt(cypherText, key);
    double score = scorer.getScore(plainText);

    Resultable r = new Result(plainText, key, score);

    try {
      queue.put(r);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
Example #3
0
  public void run() {
    RailFence rf = new RailFence(); // create railfence obj

    String plainText = rf.decrypt(cypherText, key); // decrypt the cypher text using a given key
    // get the score
    double score = ts.getScore(plainText); // get the score of text

    Resultable r = new Result(plainText, key, score); // Create a result object with text,key,score

    try {
      queue.put(r); // put r on the queue
      System.out.println("object added");
    } catch (InterruptedException e1) {
      e1.printStackTrace();
    }
  }