Return to Snippet

Revision: 9626
at November 14, 2008 21:21 by nicolaspar


Initial Code
function obuscar($str, $key) {
	if( ! defined( 'obuscar_hash' ) ) define( 'obuscar_hash', '545487875458715154879664164' );
	srand( obuscar_hash );
	$salida = '';
	$total = strlen($str);
	for( $i = -1; ++$i < $total; ){
		for( $j = -1; ++$j < ord(substr($key, $i % strlen($key), 1)); ) $toss = rand(0, 255);
		$mascara = rand(0, 255);
		$salida .= chr( ord( substr( $str, $i, 1) ) ^ $mascara);
	}
	return $salida;
}

echo obuscar('nicolas pardo','Mykey');
echo "<hr>";
echo obuscar('MS¬Š0­9k6g','Mykey');

Initial URL


Initial Description
Ofuscar strings

Initial Title
Ofuscar strings

Initial Tags


Initial Language
PHP