ucenter 用戶密碼加密方式

xxx_common_member(論壇用戶表)這個表中的密碼是在用戶註冊的時候,$password = md5(random(10))生成的,並且這個隨機數沒有被保存下來。修改以後仍是能登錄的。密碼按照xxx_ucenter_members中的爲準。
  xxx_ucenter_members(ucenter的用戶表)
 ucenter的用戶的加密方法以下:
  加密密碼:md5(md5($password).$salt) $salt爲random函數返回的字符串$hash
  $salt便是xxx_ucenter_members中的字段salt的值
  random函數的代碼以下:
  <?php
  function random($length, $numeric = 0) {
  PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
  if($numeric) {
  $hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
  } else {
  $hash = '';
  $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
  $max = strlen($chars) - 1;
  for($i = 0; $i < $length; $i++) {
  $hash .= $chars[mt_rand(0, $max)];
  }
  }
  return $hash;
  exit;
  }

  ?> php

看了下uc源碼:model/user.php sql

function add_user($username, $password, $email, $uid = 0, $questionid = '', $answer = '') {
$salt = substr(uniqid(rand()), -6);
$password = md5(md5($password).$salt);
$sqladd = $uid ? "uid='".intval($uid)."'," : '';
$sqladd .= $questionid > 0 ? " secques='".$this->quescrypt($questionid, $answer)."'," : " secques='',";
$this->db->query("INSERT INTO ".UC_DBTABLEPRE."members SET $sqladd username='$username', password='$password', email='$email', regip='".$this->base->onlineip."', regdate='".$this->base->time."', salt='$salt'");
$uid = $this->db->insert_id();
$this->db->query("INSERT INTO ".UC_DBTABLEPRE."memberfields SET uid='$uid'");
return $uid;
}
dom

相關文章
相關標籤/搜索