#!/bin/bash
# CptS 427/527 Test Script for Program #1 -- Caesar Cipher
# Revised:  14 September 2013, by AD McKinnon

echo "CptS 427/527 Program #1 Test Script"

echo " "
echo "****** Encipher a file ******"
./caesarCipher -i message.plaintext -k 42 -o message.ciphertext

echo " "
echo "****** Precomputing a priori probabilities ******"
./charFreqGen -i writing_sample.text -o char.probability -t 5

echo " "
echo "****** Launching the statistical attack ******"
./caesarAttack -c message.ciphertext -f char.probability -p phi_values.txt -o message.decrypted -r 1

echo " "
echo "--- Caesar Attack Comparison ---"
echo "--------------------------------"
diff -s message.decrypted message.plaintext | head
echo "--------------------------------"

echo " "
echo "****** Launching the statistical attack, but with 2nd choice key ******"
./caesarAttack -c message.ciphertext -f char.probability -p phi_values.txt -o message.decrypted2 -r 2

echo " "
echo "--- Caesar Attack Comparison, with 2nd choice key ---"
echo "-----------------------------------------------------"
diff -s message.decrypted2 message.plaintext | head
echo "-----------------------------------------------------"

