Helping ordinary people create extraordinary websites!

A Reversible Encryption Routine for PHP

By Tony Marston
2005-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;

$fudgefactor[] = $fudge;
If a $modulus value has been supplied we use it and possibly reverse the sign on the output value.
 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
} // if
There is no more 'fudging' left to do, so we can return the value to the calling process.
    return $fudge; 


} // _applyFudgeFactor




Tutorial pages:
 1 Votes

You might also want to check these out:


Leave a Comment on "A Reversible Encryption Routine for PHP"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS