나는 웹 서버로 mac을 사용하고 프레임 워크로 codeigniter를 사용했습니다. authetication 들어, 나는 탱크 인증을 적용했습니다. 하나의 문제가 발생합니다 :다른 시스템의 탱크 승인 (Mac 및 Linux) 다른 비밀번호 생성 해시 코드
이전 : 저는 웹 서버로 mac을 사용하여 로그인하는 것이 좋습니다.
지금 : 저는 웹 서버로 리눅스를 사용했습니다. 같은 데이터베이스를 가져 왔고 웹 사이트도 잘 돌아갔습니다. 그러나, 나는에 로그인 할 수 없습니다.
그래서 내가 Mac 및 Linux에서 동일한 비밀번호를 사용하여 등록하는 테스트, 그것은 다른 암호 해시 코드를 생성 것을 발견했다.리눅스 :
$P$Bh3B8uGDw0yGO1e/ytCUw2jXcswkso1
맥 :
$2a$08$jBCiR79fHN6xzOw5sB09beFifwU08nQdO0Au8P3hxSvIUnoepKfwW
내 질문은이 : 시스템에 대한이 문제인가? 또는 PHP 버전?
또는 php의 md5() 함수에 관한 것입니까?
나는 탱크 인증에 암호 해시의 일부 코드를 제시 :function PasswordHash($iteration_count_log2, $portable_hashes)
{
$this->itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
$iteration_count_log2 = 8;
$this->iteration_count_log2 = $iteration_count_log2;
$this->portable_hashes = $portable_hashes;
$this->random_state = microtime();
if (function_exists('getmypid'))
$this->random_state .= getmypid();
}
function get_random_bytes($count)
{
$output = '';
if (is_readable('/dev/urandom') &&
($fh = @fopen('/dev/urandom', 'rb'))) {
$output = fread($fh, $count);
fclose($fh);
}
if (strlen($output) < $count) {
$output = '';
for ($i = 0; $i < $count; $i += 16) {
$this->random_state =
md5(microtime() . $this->random_state);
$output .=
pack('H*', md5($this->random_state));
}
$output = substr($output, 0, $count);
}
return $output;
}
function encode64($input, $count)
{
$output = '';
$i = 0;
do {
$value = ord($input[$i++]);
$output .= $this->itoa64[$value & 0x3f];
if ($i < $count)
$value |= ord($input[$i]) << 8;
$output .= $this->itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
break;
if ($i < $count)
$value |= ord($input[$i]) << 16;
$output .= $this->itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
break;
$output .= $this->itoa64[($value >> 18) & 0x3f];
} while ($i < $count);
return $output;
}
function HashPassword($password)
{
$random = '';
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
$random = $this->get_random_bytes(16);
$hash =
crypt($password, $this->gensalt_blowfish($random));
if (strlen($hash) == 60)
return $hash;
}
if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
if (strlen($random) < 3)
$random = $this->get_random_bytes(3);
$hash =
crypt($password, $this->gensalt_extended($random));
if (strlen($hash) == 20)
return $hash;
}
if (strlen($random) < 6)
$random = $this->get_random_bytes(6);
$hash =
$this->crypt_private($password,
$this->gensalt_private($random));
if (strlen($hash) == 34)
return $hash;
# Returning '*' on error is safe here, but would _not_ be safe
# in a crypt(3)-like function used _both_ for generating new
# hashes and for validating passwords against existing hashes.
return '*';
}
어떤 생각? Google에서이 문제를 검색했지만 정보가 거의 없습니다. 친절하게 도와 주실 수 있습니까?
아, 어쩌면 CRYPT_BLOWFISH에 관하여 .. 감사합니다. Linux에는 CRYPT_BLOWFISH가 없습니다.
http://en.wikipedia.org/wiki/Salt_(cryptography) –