purpose: Multiliteral to Uniliteral Cipher Converter
version: v1.0
creator: Dr MindHacker [Cory Michael Boston]
contact: [drmindhaxor]@yahoo.com
define("UNIQUE", 0);
define("REPEAT", 1);
define("TOTAL", 20000);
define("TRUE", 1);
define("FALSE", 0);
// globals
$ctext[] = "";
$unitext[] = "";
$scans = 0;
$graphs = 0;
$spaces[] = "";
// map digraphs to unigraphs
function PolyToUni()
{
$AlphaVars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$x = 0;
$ptext = "";
global $graphs;
global $unitext;
global $spaces;
global $ctext;
global $scans;
for($x = 0; $x < $graphs; $x++)
{
if(strncmp($ctext[$x], "--", 2) == 0)
{
if(strncmp($ctext[$x - 1], "--", 2) != 0)
{ $ptext .= " "; }
}
else { $ptext .= $AlphaVars[$unitext[$x]]; }
}
//echo all the html crap here
// along with the converted cipher text
}
// to keep the text consistently divided, if we
function ConvertCipher()
{
global $ctext;
global $graphs;
global $scans;
global $spaces;
global $unitext;
$text[] = "";
$sp = array(" ", "\n", "\r");
$text = preg_replace('/[\.|\?|,|_|!|(|)|\-+|\+|=|\'|\"|=|;|*|\$|\/|:|{|}]/i', '', $_POST['CIPHER']);
$text = str_replace($sp, "--", $text);
//$text = str_replace("\n", "--", $text);
$csize = strlen($text);
$z = 0;
for($x = 0; $x < $csize; $x++)
{
if($text[$x] != ' ')
{
if(($x != 0) && ($x % 2 == 0))
{ $z++; }
$ctext[$z] .= $text[$x];
}
}
$z++;
$csize = $z;
$repeat = UNIQUE;
$start = 1;
$total = 0;
$scanning = TRUE;
$x = 0;
// generate a non-duplicative list of digraphs
$unitext[0] = 0;
$spaces[0] = 0;
$scans = 0;
$graphs = 0;
$total = 0;
while($scanning)
{
$repeat = UNIQUE;
if(strncmp($ctext[$graphs], "--", 2) == 0)
{ $graphs++; }
else
{
if($scans > 0)
{
for($x = ($graphs - 1); $x >= 0; $x--)
{
if(strncmp($ctext[$x], $ctext[$graphs], 2) == 0)
{
$repeat = REPEAT;
$unitext[$graphs] = $unitext[$x];
$graphs++;
$x = 0;
}
}
}
if($repeat != REPEAT)
{
$unitext[$graphs] = $scans;
$scans++;
$graphs++;
}
}
if($graphs == $csize)
{ $scanning = 0; }
}
PolyToUni();
}
ConvertCipher();