【问题标题】:Password authentification between PHP and Smartphone devicesPHP 和智能手机设备之间的密码验证
【发布时间】:2011-09-13 00:10:21
【问题描述】:

我正在使用这个类来创建密码哈希。该系统由一个基于 php、iphone 设备和 android 设备构建的网页组成。我需要这些智能手机能够登录并访问存储在我的数据库服务器端的信息。最好的解决方案是什么,是否将此方法移植到目标 c 并将哈希发送到服务器?还是使用 SSL 发送密码并比较哈希服务器端更好?

class PassHash {

  // blowfish
  private static $algo = '$2a';

  // cost parameter
  private static $cost = '$10';

  // mainly for internal use
  public static function unique_salt() {
    return substr(sha1(mt_rand()),0,22);
  }

  // this will be used to generate a hash
  public static function hash($password) {

    return crypt($password,
                self::$algo .
                self::$cost .
                '$' . self::unique_salt());

  }

  // this will be used to compare a password against a hash
  public static function check_password($hash, $password) {

    $full_salt = substr($hash, 0, 29);

    $new_hash = crypt($password, $full_salt);

    return ($hash == $new_hash);

  }
}

【问题讨论】:

    标签: php objective-c authentication ssl hash


    【解决方案1】:

    将哈希“移植”到移动应用程序不是一个好主意。服务器的散列​​是唯一的,您不希望在不同的设备平台上使用不同的“散列”方法。

    在 SSL 中发送密码并让您的服务器端身份验证模型进行哈希处理。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-21
      • 1970-01-01
      • 2019-10-24
      • 1970-01-01
      • 2015-02-10
      • 2017-08-21
      • 1970-01-01
      相关资源
      最近更新 更多