<?php
include('simplecipher.class.php');
$cipher = new simpleCipher();
$message = 'Message 106: This is a "secret" message, which includes some characters that will not be encrypted.';
$messageSave = $message;
$cMessage = $cipher->encryptMessage($message);
$cMessageSave = $cMessage;
echo '<strong>encrypted:</strong> '.$cMessage.'<br>';
$tMessage = $cipher->decryptMessage($cMessage);
echo '<strong>decrypted:</strong> '.$tMessage.'<hr>';
$message = 'Notice "the" and "the" and "the" are all different in the encrypted message, making the cipher difficult to break!!!';
$cMessage = $cipher->encryptMessage($message);
echo '<strong>encrypted:</strong> '.$cMessage.'<br>';
$tMessage = $cipher->decryptMessage($cMessage);
echo '<strong>decrypted:</strong> '.$tMessage.'<hr>';
echo '<strong>We are now going to generate a new cipher map using the generateMap method</strong><br><br>';
$cipher->generateMap();
$message = 'Not only are characters mapped to replacements, the replacement character is also determined by its position in the message.';
$cMessage = $cipher->encryptMessage($message);
echo '<strong>encrypted:</strong> '.$cMessage.'<br>';
$tMessage = $cipher->decryptMessage($cMessage);
echo '<strong>decrypted:</strong> '.$tMessage.'<hr>';
echo '<strong>We will now attempt to decrypt our first message<br><br></strong>';
echo '<strong>message:</strong> '.$messageSave.'<br>';
echo '<strong>encrypted:</strong> '.$cMessageSave.'<br>';
$tMessage = $cipher->decryptMessage($cMessageSave);
echo '<strong>decrypted:</strong> '.$tMessage.'<br><br>';
echo '<strong>which did not work because the map changed. We can encrypt it using the new map.</strong><br><br>';
$cMessage = $cipher->encryptMessage($messageSave);
echo '<strong>encrypted:</strong> '.$cMessage.'<br>';
$tMessage = $cipher->decryptMessage($cMessage);
echo '<strong>decrypted:</strong> '.$tMessage.'<hr>';
?>
|