我使用这个类来创建密码散列。该系统由一个建立在php、iphone设备和android设备上的网页组成。我需要这些智能手机能够登录并访问存储在我的数据库服务器端的信息。最好的解决方案是什么,是将此方法移植到objective 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);
}
}发布于 2012-11-23 09:12:07
将散列“移植”到移动应用程序中并不是一个好主意。服务器的散列是唯一的,您不希望在不同的设备平台上使用不同的“散列”方法。
在SSL中发送密码,并让您的服务器端身份验证模型执行散列。
https://stackoverflow.com/questions/6315336
复制相似问题