Ignore:
Timestamp:
Oct 14, 2007 7:19:17 AM (17 years ago)
Author:
quinn
Message:

Added length arg to *Signature functions; added App::setQuery() method; FormValidator? msg rewording.

File:
1 edited

Legend:

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

    r264 r282  
    708708 * @param   string  $val    The string to sign.
    709709 * @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.
    710711 * @return  string  The original value with a signature appended.
    711712 */
    712 function addSignature($val, $salt=null)
     713function addSignature($val, $salt=null, $length=18)
    713714{
    714715    $app =& App::getInstance();
     
    723724    }
    724725
    725     return $val . '-' . mb_substr(md5($salt . md5($val . $salt)), 0, 18);
     726    return $val . '-' . mb_substr(md5($salt . md5($val . $salt)), 0, $length);
    726727}
    727728
     
    750751 * @return  bool    True if the signature matches the var.
    751752 */
    752 function verifySignature($signed_val, $salt=null)
     753function verifySignature($signed_val, $salt=null, $length=18)
    753754{
    754755    // Strip the value from the signed value.
    755756    $val = removeSignature($signed_val);
    756757    // 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)) {
    758759        // Signature verified.
    759760        return true;
Note: See TracChangeset for help on using the changeset viewer.