ed as alternative unique code for the input when youfound a duplicated code in your database (same code but different input -although it is unlikely to happen but it will happen). Chances to get aduplicated code is about n/(32^6) or n/1,073,741,824 where n is the number of records in your database.
As you can see, the output results are quiterandom although you only have one character different in the input string. Theoutput is always consistent, for the same input you will always get the sameoutput.
To make the output more unpredictable by theothers, you can scramble the values in the $base32 array or/and add inyour ownprivate keyor/and XOR the value of $val with a value from range0 to 31.
For example toscramble the values in the $base32 array, you canchange the positionof the values or/and replace the value with another (make sure the replacedvalue is URL safe character).
For example to add in private key, you can add in additional stringwhen calling the md5() function, e.g.:
$hex = md5('my-secret-key'.$input.'my-another-secret-key');For example to XOR the value of $val with valueof 18:
$out .= $base32[$val ^ 18];
摘自 w397090770