Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]funkcja crypt - jak uzyć w fomularzu ?
aleo
post
Post #1





Grupa: Zarejestrowani
Postów: 137
Pomógł: 0
Dołączył: 23.08.2008

Ostrzeżenie: (0%)
-----


Witam chę użyć funkcję crypt w fomularzu tylko jak ? ciąg znaków kodowany przez tą funkcje jest losowy
robie
CODE
$password="matt01";
print(crypt($password));


i potem przy sprawdzaniu formularza z hasłem i loginem daję
CODE
$passwords = array("matt" => "$1$gtP0U8h0$r5kAEZsCQwuj5XDl9BtEh");

if (!$_POST["username"] or !$_POST["password"]) {
echo " wprowadz nazwe uzytkownika i haslo " ;
}
$salt = substr($passwords[$_POST["username"]], 0 , 2 ) ;
if (crypt($_POST["password"], $salt)
== $passwords[$_POST["username"]]) {
echo "logowanie zakonczone sukcesem";
$_SESSION["auth_username"] =$_POST["username"];
}
else {
echo "logowanie nieudane";
}


?>


Tylko ze funckja co chwilę generuje inne hasło (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) więc nie można się zalogować , może znacie jakieś inner rozwiązania z szyfrowaniem haseł ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
erix
post
Post #2





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Z manuala:
  1. <?php
  2. $password = crypt('mypassword'); // let the salt be automatically generated
  3.  
  4. /* You should pass the entire results of crypt() as the salt for comparing a
  5.   password, to avoid problems when different hashing algorithms are used. (As
  6.   it says above, standard DES-based password hashing uses a 2-character salt,
  7.   but MD5-based hashing uses 12.) */
  8. if (crypt($user_input, $password) == $password) {
  9.  echo "Password verified!";
  10. }
  11. ?>
Go to the top of the page
+Quote Post

Posty w temacie
- aleo   [PHP]funkcja crypt - jak uzyć w fomularzu ?   23.11.2008, 14:46:42
- - piotrooo89   md5?   23.11.2008, 14:49:27
- - aleo   ok a dla ciekawośći zapytam jakby tu zrobić z fun...   23.11.2008, 14:55:14
- - erix   Z manuala: [PHP] pobierz, plaintext <?php$passw...   23.11.2008, 15:44:17


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 13.10.2025 - 19:07