Exemplo n.º 1
0
 /**
  * Generate a password hash
  *
  * @param string $passwd the password to turn into a hash
  * @return string the hashed password - ready for use
  */
 public function create_hash($passwd)
 {
     switch ($GLOBALS['phpgw_info']['server']['encryption_type']) {
         case 'CRYPT':
             return '{CRYPT}' . crypt($passwd, $this->_shake_salt(CRYPT_SALT_LENGTH));
         case 'MD5':
             return "{MD5}" . base64_encode(phpgwapi_common::hex2bin(md5($passwd)));
         case 'SHA':
             return "{SHA}" . base64_encode(phpgwapi_common::hex2bin(sha1($passwd)));
         case 'SMD5':
             $salt = $this->_shake_salt(4);
             return "{SMD5}" . base64_encode(phpgwapi_common::hex2bin(md5($passwd . $salt) . $salt));
         case 'SSHA':
         default:
             $salt = $this->_shake_salt(4);
             return '{SSHA}' . base64_encode(phpgwapi_common::hex2bin(sha1($passwd . $salt) . $salt));
     }
 }