|
|||
|
Hello, my name is Judas Gutenberg and this is my blaag (pronounced as you would the vomit noise "hyroop-bleuach").
linksdecay & ruin got that wrong appropriate tech fun social media stuff Like asecular.com (nobody does!) Like my brownhouse: |
new games for myself Friday, June 11 2004
function AddCharacters($chrOne, $chrTwo)
{
$intOne=ord($chrOne);
$intTwo=ord($chrTwo);
$intRollCombo=$intOne + $intTwo;
if ($intRollCombo>255)
{
$intRollCombo=$intRollCombo-256;
}
return $intRollCombo;
}
function SubtractCharacters($chrOne, $chrTwo)
{
$intOne=ord($chrOne);
$intTwo=ord($chrTwo);
$intRollCombo=$intOne - $intTwo;
if ($intRollCombo<0)
{
$intRollCombo=256+$intRollCombo;
}
return $intRollCombo;
}
function CombineStrings($strOne, $strTwo, $strOperation, $strType)
{
$out="";
$intLenOne=strlen($strOne);
$intLenTwo=strlen($strTwo);
$strNonDec="";
if ($strType=="fromhex")
{
for ($i=0; $i<$intLenOne; $i=$i+2)
{
$strPair=substr($strOne, $i, 2);
$strNonDec.=chr(hexdec($strPair));
}
$strOne=$strNonDec;
}
$intLenOne=strlen($strOne);
if ($strTwo=="")
{
$strTwo=" ";
}
if ($intLenOne>$intLenTwo)
{
while (strlen($strTwo)<$intLenOne)
{
$strTwo.=$strTwo;
}
}
$strTwo=substr($strTwo, 0, $intLenOne-1);
for ($i=0; $i<$intLenOne; $i++)
{
$chrThisOne=substr($strOne, $i, 1);
$chrThisTwo=substr($strTwo, $i, 1);
if ($strOperation=="add")
{
$chrSum=chr(AddCharacters($chrThisOne, $chrThisTwo));
}
else if ($strOperation=="subtract")
{
$chrSum=chr(SubtractCharacters($chrThisOne, $chrThisTwo));
}
if ($strType=="tohex")
{
$chrSum=str_pad(dechex(ord($chrSum)), 2, "0", STR_PAD_LEFT);
}
$out.=$chrSum;
}
return $out;
}
function AddStrings($strOne, $strTwo)
{
return CombineStrings($strOne, $strTwo, "add", "");
}
function SubtractStrings($strOne, $strTwo)
{
return CombineStrings($strOne, $strTwo, "subtract", "");
}
function Encrypto($strIn, $strKey)
{
$out= strtoupper(CombineStrings($strIn, $strKey, "add", "tohex"));
//$out=Compress($out);
return $out;
}
function Decrypto($strIn, $strKey)
{
//$strIn=Decompress($strIn);
$out=CombineStrings($strIn, $strKey, "subtract", "fromhex");
return $out;
}
For linking purposes this article's URL is: previous | next |
||