Posted in PHP on May 18th, 2005 Comments Off
Fairly self-explanatory. This example gets its input from a file called ‘filename’, strips the HTML markup and displays what’s left in the browser.
<?
$fp=fopen (”filename”,”r”);
$file=fread ($fp,filesize (”filename”));
$fclose($fp);
$pattern=”‘<[\/\!]*?[^<>]*?>’si”;
$replace=””;
$file = preg_replace ($pattern, $replace, $filev[$r]);
print “$file”;
?>
Read Full Post »
Posted in PHP on May 18th, 2005 Comments Off
To use this code, simply call the EnDeCrypt function with two parameters: the string you want to encrypt/decrypt; the encryption password.
<?
function EnDeCrypt($plaintext,$strPwd)
{
$intLength=strlen($strPwd);
$sbox=Array();
$key=Array();
$cipher=”;
$i=0;
$j=0;
for ($a=0; $a<256; $a++)
{
$key[$a]=ord(substr($strPwd,($a % $intLength),1));
$sbox[$a]=$a;
}
$b=0;
for ($a=0; $a<256; $a++)
{
$b=($b + $sbox[$a] + $key[$a]) % 256;
$tempSwap = $sbox[$a];
$sbox[$a] = $sbox[$b];
$sbox[$b] = $tempSwap;
}
for ($a=0; $a<strlen($plaintext); $a++)
{
$i=($i+1) % 256;
$j=($j + $sbox[$i]) % 256;
$temp=$sbox[$i];
$sbox[$i]=$sbox[$j];
$sbox[$j]=$temp;
$k=$sbox[($sbox[$i] + $sbox[$j]) % 256 [...]
Read Full Post »