【问题标题】:Social Engine Password Encryption Help社交引擎密码加密帮助
【发布时间】:2010-07-17 17:58:12
【问题描述】:

我想创建一个链接到社交引擎数据库的另一个注册页面,但是当我 MD5 密码并将其存储在 se_users 表中时,用户无法登录,我相信社交引擎有另一种加密方法,谁能给我一个以社交引擎方式加密密码的功能?

这是他们的功能,但我不知道如何在我的脚本上实现它:

function user_password_crypt($user_password)
{
global $setting;

if( !$this->user_exists )
{
  $method = $setting['setting_password_method'];
  $this->user_salt = randomcode($setting['setting_password_code_length']);
}

else
{
  $method = $this->user_info['user_password_method'];
}

// For new methods
if( $method>0 )
{
  if( !empty($this->user_salt) )
  {
    list($salt1, $salt2) = str_split($this->user_salt, ceil(strlen($this->user_salt) / 2));
    $salty_password = $salt1.$user_password.$salt2;
  }
  else
  {
    $salty_password = $user_password;
  }
}

$user_password_crypt = md5($salty_password);

return $user_password_crypt;
}

谢谢

【问题讨论】:

  • 你的意思是散列,而不是加密。

标签: php encryption md5 social-networking


【解决方案1】:

社交引擎使用默认安全盐、用户盐和用户密码的组合来加密密码,所以你只需要将这三个数据结合起来转换成md5。

$enc_password = md5('default_decurity_salt','user_password','user_salt');

前。 - MD5('6e3cf54ce0aa10bb69d69926e82b62b3be9022b9'.'123456'.'3486524');?

它会起作用的。

【讨论】:

    【解决方案2】:

    你可以试试这个

    md5('default_salt','user_salt','user_password');

    【讨论】:

      【解决方案3】:

      在通过 MD5 运行密码之前,他们会在密码中添加和添加盐。

      这是盐的生成方式,看起来像一个随机字符串,其长度在应用程序配置中指定“

      $this->user_salt = randomcode($setting['setting_password_code_length']);
      

      这里他们把一个盐分成两半,左边放在密码前面,右边放在后面"

      list($salt1, $salt2) = str_split($this->user_salt, ceil(strlen($this->user_salt) / 2));
      $salty_password = $salt1.$user_password.$salt2;
      

      现在他们对加盐密码进行哈希处理:

      $user_password_crypt = md5($salty_password);
      

      为了正确解密,您必须做的是读取该用户的盐。

      $username = $POST['username'];
      $password = $POST['password'];
      $user = get_user_from_database($username);
      list($salt1, $salt2) = str_split($user->salt, ceil(strlen($user->salt) / 2));
      
      $salted_password = md5($salt1.$password.$salt2);
      
      if($salted_password == $user->crypted_password) {
        echo "Login successful";
      } else {
        echo "Invalid password";
      }
      

      Here is the Wikipedia page 谈密码学中的盐。

      【讨论】:

      • 您好,感谢您的回答,但是如果其中一部分是随机码,生成的 md5 哈希如何始终相同?
      • 不是每次都是随机的。第一次创建用户帐户时,会生成一个随机代码并与密码一起保存。每次获取用户的信息,他的salt都会是你第一次生成的字符串,不再是随机的了。
      【解决方案4】:

      几件事:

      您是否存储了用户密码的 MD5 哈希?根据您发布的代码,Social Engine 正在对哈希进行加盐(一种防止彩虹表的方法)。

      另一方面,MD5 散列不是散列密码的加密安全方法。此外,在登录时散列密码并传输散列并不比以纯文本形式传递密码更安全。为了安全登录,您需要通过 HTTPS 登录(或者通过加密密码不太正确)

      【讨论】:

        猜你喜欢
        • 2013-05-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-27
        • 2017-11-03
        相关资源
        最近更新 更多