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 (1 - 3)
piotrooo89
post
Post #2


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




md5?
Go to the top of the page
+Quote Post
aleo
post
Post #3





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

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


ok
a dla ciekawośći zapytam jakby tu zrobić z funkcją crypt php ? żeby działał w moim fomularzu ?
Go to the top of the page
+Quote Post
erix
post
Post #4





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

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: 23.08.2025 - 23:23