All pastes #419032 Raw Edit

Someone

public text v1 · immutable
·published 2007-04-01 00:17 UTC
rendered paste body
<?

	$theString = "AAAACCCC";
	
	$encrypted = encrypt($theString);
	
	echo "The encrypted version of {$theString} is {$encrypted}<br>\n";
	
	echo "Now we will test the decrypt function<br>\n";
	
	$decrypted = decrypt($encrypted);
	
	echo "The decrypted version of {$encrypted} is {$decrypted}";

	function encrypt($string)
	{
		
		// replace all A's with B's and all C's with D's
		$string = str_replace('A', 'B', $string);
		$string = str_replace('C', 'D', $string);
		
		return($string);
		
	}
	
	function decrypt($string)
	{
		
		// to decrypt all we have to do is replace all B's with A's and all D's with C's
		
		$string = str_replace('B', 'A', $string);
		$string = str_replace('D', 'C', $string);
		
		return($string);
		
	}

?>