PHP和Smartphone设备之间的密码认证

问题描述

| 我正在使用此类来创建密码哈希。该系统包括一个基于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()),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,29);

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

    return ($hash == $new_hash);

  }
}
    

解决方法

        “将哈希值移植”到移动应用程序不是一个好主意。服务器的哈希是唯一的,并且您不希望在不同的设备平台上使用不同的“哈希”方法。 使用SSL发送密码,然后让您的服务器端身份验证模型执行哈希处理。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...