AGOW_CMS 1.0
Shiftare l' ASCII
Istanziare il coderino ...
$myCoder = new Encoder();
$myCoder->key = md5('lamiasegretissimachiave');
$myCoder->numberX = 17; // scaramanticamente
Offuscare:
$stringaOffuscata = $myCoder->Encode($laMiaPassword);
Rivedere:
$laMiaPassword = $myCoder->Decode($stringaOffuscata);
/////////////////////////////// CODING
class Encoder{
var $key;
var $numberX;
function Encoder(){
$this->numberX=144;
$this->key="la tua chiave";
}
function Encode($strToEncode){
$strEncoded=""; $y = 0;
for ($i = 0; $i < strlen($strToEncode); $i++){
$letter = substr($strToEncode, $i, 1);
if ($y >= strlen($this->key))
$y -= strlen($this->key);
$l = substr($this->key, $y, 1);
$y++;
$NewC = (ord($letter)+$this->numberX) + ord($l);
while ($NewC > 255) $NewC -= 255;
$strEncoded .= chr($NewC);
}
return $strEncoded;
}
function Decode($strEncoded){
$strDecoded=""; $y = 0;
for ($i = 0; $i < strlen($strEncoded); $i++){
$letter = substr($strEncoded, $i, 1);
if ($y >= strlen($this->key))
$y -= strlen($this->key);
$l = substr($this->key, $y, 1);
$y++;
$NewC = (ord($letter)-$this->numberX) - ord($l);
while ($NewC < 0) $NewC += 255;
$strDecoded .= chr($NewC);
}
return $strDecoded;
}
}
/////////////////////////////// END CODING
Autore: #ffffff (10-02-2007 00:00:00)
07-01-2009 - PM 02:53