簡體   English   中英

PHP與智能手機設備之間的密碼認證

[英]Password authentification between PHP and Smartphone devices

我正在使用這個 class 來創建密碼哈希。 該系統由基於 php、iphone 設備以及 android 設備構建的網頁組成。 我需要這些智能手機能夠登錄並訪問存儲在我的數據庫服務器端的信息。 最好的解決方案是什么,是否將此方法移植到目標 c 並將 hash 發送到服務器? 還是使用 SSL 發送密碼並比較 hash 服務器端是否更好?

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);

  }
}

將哈希“移植”到移動應用程序不是一個好主意。 服務器的 hash 是獨一無二的,您不希望在不同的設備平台上使用不同的“散列”方法。

在 SSL 中發送密碼,讓您的服務器端身份驗證 model 進行哈希處理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM