Ignore:
Timestamp:
Nov 23, 2005 9:29:33 PM (19 years ago)
Author:
scdev
Message:

More bugs and shifting things about.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Utilities.inc.php

    r21 r22  
    532532 * @access  public
    533533 * @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.
    535535 * @return  string  The original value with a signature appended.
    536536 */
    537 function addSignature($val, $key=null)
     537function addSignature($val, $seed_key=null)
    538538{
    539539    if ('' == $val) {
     
    541541    }
    542542   
    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);
    548548}
    549549
     
    566566 * @access  public
    567567 * @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.
    569569 * @return  bool    True if the signature matches the var.
    570570 */
    571 function verifySignature($signed_val, $key=null)
     571function verifySignature($signed_val, $seed_key=null)
    572572{
    573573    // Strip the value from the signed value.
    574     $val = substr($signed_val, 0, strrpos($signed_val, '-'));
     574    $val = removeSignature($signed_val);
    575575    // 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)) {
    577577        // Signature verified.
    578578        return true;
Note: See TracChangeset for help on using the changeset viewer.