A Reversible Encryption Routine for PHP
By Tony Marston2005-04-15
The ApplyFudgeFactor function
This function will return an adjustment value using the contents of the $fudgefactor array. Note that $fudgefactor is passed by reference so that it can be modified.
function _applyFudgeFactor (&$fudgefactor)Here we extract the first entry in the array and remove it from the array.
{
$fudge = array_shift($fudgefactor);Next we add in the optional $adj value and put the result back into the end of the array.
$fudge = $fudge + $this->adj;If a $modulus value has been supplied we use it and possibly reverse the sign on the output value.
$fudgefactor[] = $fudge;
if (!empty($this->mod)) { // if modifier has been supplied
if ($fudge % $this->mod == 0) { // if it is divisible by modifier
$fudge = $fudge * -1; // reverse then sign
} // if
} // ifThere is no more 'fudging' left to do, so we can return the value to the calling process.
return $fudge;
} // _applyFudgeFactor
Tutorial Pages:
» A Reversible Encryption Routine for PHP
» Rotating each character a fixed number of positions
» Swapping between two different character strings
» Manipulating the index number between the two strings
» Customising the Encryption Algorithm
» Class Variables
» Class Constructor
» The ConvertKey function
» The ApplyFudgeFactor function
» The CheckRange Function
» The Decrypt function
» Using the Encryption Class
» Summary
