Changeset 282 for trunk/lib/Utilities.inc.php
- Timestamp:
- Oct 14, 2007 7:19:17 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Utilities.inc.php
r264 r282 708 708 * @param string $val The string to sign. 709 709 * @param string $salt (Optional) A text key to use for computing the signature. 710 * @param string $length (Optional) The length of the added signature. Longer signatures are safer. Must match the length passed to verifySignature() for the signatures to match. 710 711 * @return string The original value with a signature appended. 711 712 */ 712 function addSignature($val, $salt=null )713 function addSignature($val, $salt=null, $length=18) 713 714 { 714 715 $app =& App::getInstance(); … … 723 724 } 724 725 725 return $val . '-' . mb_substr(md5($salt . md5($val . $salt)), 0, 18);726 return $val . '-' . mb_substr(md5($salt . md5($val . $salt)), 0, $length); 726 727 } 727 728 … … 750 751 * @return bool True if the signature matches the var. 751 752 */ 752 function verifySignature($signed_val, $salt=null )753 function verifySignature($signed_val, $salt=null, $length=18) 753 754 { 754 755 // Strip the value from the signed value. 755 756 $val = removeSignature($signed_val); 756 757 // If the signed value matches the original signed value we consider the value safe. 757 if ($signed_val == addSignature($val, $salt )) {758 if ($signed_val == addSignature($val, $salt, $length)) { 758 759 // Signature verified. 759 760 return true;
Note: See TracChangeset
for help on using the changeset viewer.