如何解决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发送密码,然后让您的服务器端身份验证模型执行哈希处理。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。