Changeset 1320

Show
Ignore:
Timestamp:
02/02/08 14:12:49 (10 months ago)
Author:
mikey
Message:

enhanced net::stubbles::php::string::stubMD5Encoder: can now use prefixes and postfixes for encoding, may be useful for salts
added unit test for net::stubbles::php::string::stubMD5Encoder

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/php/string/stubMd5Encoder.php

    r1224 r1320  
    1717{ 
    1818    /** 
     19     * prefix of the value to filter 
     20     * 
     21     * @var  string 
     22     */ 
     23    protected $prefix = ''; 
     24    /** 
     25     * postfix of the value to filter 
     26     * 
     27     * @var  string 
     28     */ 
     29    protected $postfix = ''; 
     30 
     31    /** 
     32     * constructor 
     33     * 
     34     * @param  string  $prefix   prefix of the value to filter 
     35     * @param  string  $postfix  postfix of the value to filter 
     36     */ 
     37    public function __construct($prefix = '', $postfix = '') 
     38    { 
     39        $this->setPrefix($prefix); 
     40        $this->setPostfix($postfix); 
     41    } 
     42 
     43    /** 
     44     * sets the prefix 
     45     * 
     46     * @param  string  $prefix  prefix of the value to filter 
     47     */ 
     48    public function setPrefix($prefix) 
     49    { 
     50        $this->prefix = $prefix; 
     51    } 
     52 
     53    /** 
     54     * sets the postfix 
     55     * 
     56     * @param  string  $postfix  postfix of the value to filter 
     57     */ 
     58    public function setPostfix($postfix) 
     59    { 
     60        $this->postfix = $postfix; 
     61    } 
     62 
     63    /** 
    1964     * encodes a string 
    2065     * 
     
    2469    public function encode($string) 
    2570    { 
    26         return md5($string); 
     71        return md5($this->prefix . $string . $this->postfix); 
    2772    } 
    2873