src/test/java/org/nyu/crypto/HillClimberTest.java
@Test
    @SuppressWarnings("unchecked")
    public void simulateHillClimbingPlaintextDigraph() {
        Simulation simulation = simulator.createSimulation();

        // now compute plaintext digraph for our experiment
        double[][] digraph = digrapher.computePutativeDigraph(simulation.getMessage());

        String plaintext = simulation.getMessage();

        Climb climb = hillClimber.climb(simulation.getCiphertext(), digraph);
        String putative = climb.getPutative();

        logger.info("putative : " + putative);
        logger.info("plaintext: " + simulation.getMessage());

        int score = 0;
        for (int i = 0; i < plaintext.length(); i++) {
            if (putative.charAt(i) == plaintext.charAt(i)) score++;
        }
        logger.info("score: " + score);
    }
// TODO - change the digraph generation from dictionary to randomly generated messages!
change the digraph generation from dictionary to randomly generated messages!
change the digraph generation from dictionary to randomly generated messages!
@Test
    @SuppressWarnings("unchecked")
    public void simulateHillClimbingPlaintextDigraph() {
        Simulation simulation = simulator.createSimulation();
        double[][] digraph = digrapher.computePutativeDigraph(simulation.getMessage());
        String plaintext = simulation.getMessage();
        Climb climb = hillClimber.climb(simulation.getCiphertext(), digraph);
        String putative = climb.getPutative();
        logger.info("putative : " + putative);
        logger.info("plaintext: " + simulation.getMessage());
        int score = 0;
        for (int i = 0; i < plaintext.length(); i++) {
            if (putative.charAt(i) == plaintext.charAt(i)) score++;
        }
        logger.info("score: " + score);
    }
@ Test @ SuppressWarnings ( "unchecked" ) public void simulateHillClimbingPlaintextDigraph ( ) { Simulation simulation = simulator . createSimulation ( ) ; double [ ] [ ] digraph = digrapher . computePutativeDigraph ( simulation . getMessage ( ) ) ; String plaintext = simulation . getMessage ( ) ; Climb climb = hillClimber . climb ( simulation . getCiphertext ( ) , digraph ) ; String putative = climb . getPutative ( ) ; logger . info ( "putative : " + putative ) ; logger . info ( "plaintext: " + simulation . getMessage ( ) ) ; int score = 0 ; for ( int i = 0 ; i < plaintext . length ( ) ; i ++ ) { if ( putative . charAt ( i ) == plaintext . charAt ( i ) ) score ++ ; } logger . info ( "score: " + score ) ; }
TODO - change the digraph generation from dictionary to randomly generated messages!
TODO - change the digraph generation from dictionary to randomly generated messages!
// now compute plaintext digraph for our experiment