Cesar's Code

Algorithm is very simple: each letter is substituted by a letter that is three positions ahead in alphabet. The three letter from the end are substituted by first three letters.


Enter text to code:



PHP code:
<?php
	$tablica =  "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	$tablica2 = "abcdefghijklmnopqrstuvwxyz";
	$lentab = strlen($tablica);
	if(isset($text)){
		print "Original text: <font color = #00FF00><tt><b> ";
		print "$text</font></tt></B><br>";
		$textcoded = "";
		$litera = false;
		for($i = 0; $istrlen($text); $i++) {
			$litera = false;
			for($j = 0; $j<strlen($tablica); $j++) {
				if($tablica[$j]==$text[$i]) {
					$textcoded.=$tablica[($j+3)%$lentab];
					$litera = true;
					break;
				}
				if($tablica2[$j]==$text[$i]) {
					$textcoded.=$tablica2[($j+3)%$lentab];
					$litera = true;
					break;
				}
			}
			if(!$litera) $textcoded.=$text[$i];
		}
		print "Coded text:<font color = #FF0000><b><tt> $textcoded</font></tt></B><br>";
	}
	f();
?>


Back to main page