コード例 #1
0
  public void quiz1_q1() {
    FileResource fr = new FileResource("../secretmessage1.txt");
    String encrypted = fr.asString();

    int[] key = new int[4];
    key = tryKeyLength(encrypted, 4, 'e');
    for (int i = 0; i < 4; i++) {
      System.out.println(key[i]);
    }
  }
コード例 #2
0
  public void testTryKeyLength() {

    FileResource fr = new FileResource("athens_keyflute.txt");
    String encrypted = fr.asString();

    int[] key = new int[5];
    key = tryKeyLength(encrypted, 5, 'e');
    for (int i = 0; i < 5; i++) {
      System.out.println(key[i]);
    }
  }
コード例 #3
0
  public void breakVigenere() {

    // read in the encrypted message
    FileResource fr = new FileResource();
    String encrypted = fr.asString();

    // read in the dictionary of valid words
    FileResource dictRes = new FileResource("dictionaries/English");
    HashSet<String> dict = readDictionary(dictRes);

    String decrypted = breakForLanguage(encrypted, dict);
    System.out.println(decrypted);
  }
コード例 #4
0
  public void testBreakForAllLanguages() {

    // read in the encrypted message
    FileResource fr2 = new FileResource("athens_keyflute.txt");
    String encrypted = fr2.asString();

    HashMap<String, HashSet<String>> myMap = new HashMap<String, HashSet<String>>();

    FileResource fr = new FileResource("dictionaries/English");
    HashSet<String> dict = readDictionary(fr);

    myMap.put("English", dict);

    FileResource fr1 = new FileResource("dictionaries/Spanish");
    HashSet<String> dict1 = readDictionary(fr1);

    myMap.put("Spanish", dict1);

    breakForAllLanguages(encrypted, myMap);
  }