Helping ordinary people create extraordinary websites!

A Reversible Encryption Routine for PHP

By Tony Marston
2005-04-15

Manipulating the index number between the two strings
This involves an additional step in between converting a character into an index number using STRING1 and converting that index number into a character from STRING2. This additional step adjusts the index number at runtime according to some fixed rules. The rules must be fixed so that the same source string will always result in the same target string, otherwise it will not be possible to verify a password with one that is held on file. This method means that if the same character appears in the input string more than once that it will not generate the same corresponding character in the output string, thus making the hacker's job that much more difficult.

A common method is to use a separate character string as a 'key'. This key is reduced to an array of numbers, and it is this array of numbers that is used to adjust the index number between STRING1 and STRING2. The method I use is to take the first number from the array, add it to the index number, then move this number from the beginning to the end of the array in a rotation movement.

The beauty of this method is that even if you know the exact encryption algorithm being used it is totally useless without the key.



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