服务器上的加密与本地计算机上的加密不同 [英] Crypt is different on server than on local machine

查看:154
本文介绍了服务器上的加密与本地计算机上的加密不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP(Codeigniter)和Phils RESTserver开发API。
我正在使用带有密码和盐的crypt()创建散列。

I am developing an API using PHP (Codeigniter) and Phils RESTserver. I am creating a hash using crypt() with the password and the salt.

问题是散列是crypt()的结果算法在我的本地计算机和服务器上是不同的

The problem is that the hash that is the result of the crypt() algorithm is different on my local machine and on the server.

它在本地可以正常运行,但不能在服务器上运行(简而言之)。我知道密码和盐是相同的,因为我尝试将它们硬编码为它们。

It works fine locally but not on the server (to short). I know the password and the salt are the same because I tried them hardcoded to.

从本地计算机散列:

$2a$10$g6J7CUjJvB0JpTd7UcrowePEbqp/oBmZEpd7vS.5HFYx38f08Tb/a

服务器中的哈希:

$2jkP2/LlC/H6

有什么问题吗?

(服务器正在运行centos 5)。

(server is running centos 5).

推荐答案

您的PHP版本可能不支持用于加密的河豚哈希。输出中的$ 2a $表示您正在尝试使用CRYPT_BLOWFISH,这可能在两个平台上均不可用。

Your PHP version probably does not support blowfish hashing for crypt. The $2a$ in the output suggests you're trying to use CRYPT_BLOWFISH which may not be available on both platforms.

http://uk.php.net/crypt

PHP 5.3中的一个错误已修复。 2:

A bug was fixed in PHP 5.3.2:


修复了无效轮中的河豚行为,以返回失败字符串
( * 0或 * 1 ),而不是回退到DES。

Fixed Blowfish behaviour on invalid rounds to return "failure" string ("*0" or "*1"), instead of falling back to DES.

所以我猜您服务器中的哈希值回落到了DES,因为它仅包含盐的前2个字符。

So i'd guess the hash from your server is falling back to DES, since it contains only the first 2 characters of your salt.

这篇关于服务器上的加密与本地计算机上的加密不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆