빠르고 더러운 실험.PHP 암호 문제
이 코드를 .php
파일에 넣고 웹 호스트에서로드했습니다.
결과는 "작동합니다!" 하지만 .. 왜? 실패 했어야합니까? 여기에서 예 # 1을 다음되었습니다 http://php.net/manual/en/function.crypt.php
<?php
$pass1 = "thetimeshallwhintercows";
$salt = "temperpedic";
$crypt_pass = crypt($pass1, $salt);
if($crypt_pass == crypt("thetimeshallwhintercowz", $crypt_pass))
{
print("It works!<br/>");
print($crypt_pass );
print("<br/>");
print(crypt("thetimeshallwhintercowz", $crypt_pass));
}
else
{
print("try again....");
}
?>
예 # 1 (http://php.net/manual/en/function.crypt이어야한다. php) (코드의 주석으로)'// 소금을 자동으로 생성하게합니다'. 바로 같은 페이지에서'$ user_input = "mypassword"; '를 사용 (추가) 한 다음'$ user_input = "mypassword2";로 수정하면 의도 한대로 작동합니다. –
[Rezigned 's answer] (http://stackoverflow.com/a/20625155/1415724)는 많은 의미를 가지며 "돈에 옳다"라고 말합니다. 처음 8자는 동일하지 않아야합니다. –