Affine Cipher | +----------------------------------------------------------------------+ | | | | (c) 2002 by M.Abdullah Khaidar (khaidarmak@yahoo.com) | | | | This program is free software. You can redistribute it and/or modify | | it under the terms of the GNU General Public License as published by | | the Free Software Foundation; either version 2 of the License. | | | +----------------------------------------------------------------------+ ************************************************************************/ include "main.php"; $TITLE="Affine Encoder and Decoder"; $HEADTITLE="Affine Encoder and Decoder"; /* Affine Cipher: e(x) = ax + b mod 26 and d(y) = a^(-1) * (y - b) mod 26 */ function affine_encode($plain,$a,$b){ $cipher=""; $plain=filter($plain); $plain=check_length($plain); for($i=0;$i\n"; echo "Enter text you want to encode or decode:
\n"; echo "

\n"; echo "a :"; echo "\n"; echo "   "; echo "b:"; echo "\n"; echo "

"; echo "\n"; echo "\n"; echo "\n"; if ($process=="Encode"){ $cipher=affine_encode($plain,$keya,$keyb); echo "Text after encoding:
\n"; echo "

\n"; }elseif($process=="Decode"){ $cipher=affine_decode($plain,$keya,$keyb); echo "Text after decoding:
\n"; echo "

\n"; } bottom(); ?>