A Reversible Encryption Routine for PHP
By Tony Marston2005-04-15
The CheckRange Function
This function checks that the value in $num can actually be used as a pointer to an entry in $scramble1.
function _checkRange ($num)Indexing starts at 0, not 1, so we must subtract 1 from string length.
{
$limit = strlen($this->scramble1)-1;If the value is too high we must reduce it.
while ($num > $limit) {
$num = $num - $limit;
} // whileIf the value is too low we must increase it.
while ($num < 0) {
$num = $num + $limit;
} // whileWe can now return a valid pointer back to the calling process.
return $num;
} // _checkRange
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
