<?

$plaintext 
stripslashes($_REQUEST["plaintext"]);
$cipheredtext stripslashes($_REQUEST["cipheredtext"]);

$keyword stripslashes($_REQUEST["keyword"]);

if(
$_REQUEST["action"] == "Encrypt")
    
$cipheredtext caesar_encrypt($plaintext$keyword);

if(
$_REQUEST["action"] == "Decrypt")
    
$plaintext "not implemented yet";

    
//$plaintext = caesar_decrypt($cipheredtext, $keyword);









?>
<form method="post">
Your original message<br>
<textarea name="plaintext" cols="55" rows="6">
<?=$plaintext;?>
</textarea>
<br>
<input name="action" type="submit" value="Encrypt">
<br>
</form>

<br><br><br>

<form method="post">
Encrypted Message<br>
<textarea name="cipheredtext" cols="55" rows="6">
<?=$cipheredtext;?>
</textarea>
<br>
<input name="action" type="submit" value="Decrypt">
<br>
</form>


<?





/*
to understand the next part you have to know how to work a vigenere cipher
http://www.trincoll.edu/depts/cpsc/cryptography/vigenere.html
and you have to have a keyword
the keyword is
awesome

wr xqghuvwdqg wkh qhw sduw brx kdyh wr nqrz krz wr zrun d yljhqhuh flskhu
kwws://zzz.wulqfroo.hgx/ghswv/fsvf/fubswrjudskb/yljhqhuh.kwpo
dqg brx kdyh wr kdyh d nhbzrug
wkh nhbzrug lv
dzhvrph

wr xqghuvwdqg wkh qhaw sduw brx kdyh wr nqrz krz wr zrun d yljhqhuh flskhu
kwws://zzz.wulqfroo.hgx/ghswv/fsvf/fubswrjudskb/yljhqhuh.kwpo
dqg brx kdyh wr kdyh d nhbzrug
wkh nhbzrug lv
dzhvrph
*/

function caesar_encrypt($plaintext$shift_number)
{
    
$alphabet "abcdefghijklmnopqrstuvwxyz";
    
$alphabet preg_split('//'$alphabet, -1PREG_SPLIT_NO_EMPTY);
    
$alphabet_flip array_flip($alphabet);

    if(empty(
$shift_number))
        
$shift_number 3;

    for(
$x 0$x strlen($plaintext); $x++)
    {
        if(
in_array($plaintext[$x], $alphabet))
        {
            
$plaintext_character $plaintext[$x];
            
$plaintext_number $alphabet_flip[$plaintext_character];

            
$cipheredtext_number = ($plaintext_number $shift_number);

            if(
$cipheredtext_number >= 26)
                
$cipheredtext_number = ($cipheredtext_number 26);

            
$cipheredtext_character $alphabet[$cipheredtext_number];

            
$cipheredtext .= $cipheredtext_character;
        }
        else
            
$cipheredtext .= $plaintext[$x];
    }
    return 
$cipheredtext;
}

?>