Changeset 22 for trunk/lib/Utilities.inc.php
- Timestamp:
- Nov 23, 2005 9:29:33 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Utilities.inc.php
r21 r22 532 532 * @access public 533 533 * @param string $val The string to sign. 534 * @param string $ key(Optional) A text key to use for computing the signature.534 * @param string $seed_key (Optional) A text key to use for computing the signature. 535 535 * @return string The original value with a signature appended. 536 536 */ 537 function addSignature($val, $ key=null)537 function addSignature($val, $seed_key=null) 538 538 { 539 539 if ('' == $val) { … … 541 541 } 542 542 543 if (!isset($ key)) {544 $ key = App::getParam('signing_key');545 } 546 547 return $val . '-' . substr(md5($val . $ key), 0, 18);543 if (!isset($seed_key)) { 544 $seed_key = App::getParam('signing_key'); 545 } 546 547 return $val . '-' . substr(md5($val . $seed_key), 0, 18); 548 548 } 549 549 … … 566 566 * @access public 567 567 * @param string $signed_val A value with appended signature. 568 * @param string $ key(Optional) A text key to use for computing the signature.568 * @param string $seed_key (Optional) A text key to use for computing the signature. 569 569 * @return bool True if the signature matches the var. 570 570 */ 571 function verifySignature($signed_val, $ key=null)571 function verifySignature($signed_val, $seed_key=null) 572 572 { 573 573 // Strip the value from the signed value. 574 $val = substr($signed_val, 0, strrpos($signed_val, '-'));574 $val = removeSignature($signed_val); 575 575 // If the signed value matches the original signed value we consider the value safe. 576 if ($signed_val == addSignature($val, $ key)) {576 if ($signed_val == addSignature($val, $seed_key)) { 577 577 // Signature verified. 578 578 return true;
Note: See TracChangeset
for help on using the changeset viewer.