/**
  * Regression test for File_Passwd.crypt_sha method
  * @access public
  */
 function testcrypt_sha()
 {
     $sha = '{SHA}2iNhTgJGmg18e9G9q1ycR0sZBNw=';
     $this->assertEquals($sha, File_Passwd::crypt_sha('ab'));
 }
示例#2
0
 /**
  * Generate password with htpasswd executable
  * 
  * @access   private
  * @return   string  the crypted password
  * @param    string  $pass   the plaintext password
  * @param    string  $salt   the salt to use
  * @param    string  $mode   encyption mode, usually determined from
  *                           <var>$this->_mode</var>
  */
 function _genPass($pass, $salt = null, $mode = null)
 {
     $mode = is_null($mode) ? utf8_strtolower($this->_mode) : utf8_strtolower($mode);
     if ($mode == 'md5') {
         return File_Passwd::crypt_apr_md5($pass, $salt);
     } elseif ($mode == 'des') {
         return File_Passwd::crypt_des($pass, $salt);
     } elseif ($mode == 'sha') {
         return File_Passwd::crypt_sha($pass, $salt);
     }
     return PEAR::raiseError(sprintf(FILE_PASSWD_E_INVALID_ENC_MODE_STR, $mode), FILE_PASSWD_E_INVALID_ENC_MODE);
 }