Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

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:
» 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


 | Bookmark
Related Tutorials:
» Zend Framework Tutorial
» Port Scanning and Service Status Checking in PHP
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1