crypt($mdp);
crypt($mdp, base64_encode(CRYPT_STD_DES);
md5($mdp);
Ce qui donne pourCode : Tout sélectionner
crypt()
cyrano:$1$cv1oudjU$qskwshFBX0CvZqaZa8e4p1 (entre autres...)
crypt base 64
cyrano:MQgnBhThTQenE
md5
cyrano:e1bfd762321e409cee4ac0b6e841963c
Curieux. Essaye ce bout de code pour voir.Ça ne fonctionne dans aucun cas de figure : les seuls qui fonctionnent pour le moment, ce sont les mots de passes en clair ou ceux cryptés avec l'utilitaire htpasswd.exe en ligne de commande.
// pour générer un mot de passe .htaccess
$user = isset($_POST['user']) ? trim($_POST['user']) : null;
$pass = isset($_POST['pass']) ? trim($_POST['pass']) : null;
$salt = isset($_POST['salt']) ? trim($_POST['salt']) : null;
$salt = substr($salt, 0, CRYPT_SALT_LENGTH );
echo '<form name="form1" method="post" action="'.$_SERVER['PHP_SELF'].'">';
echo '<input name="user" type="text" size="20" value="'.$user.'">';
echo '<input name="pass" type="text" size="20" value="'.$pass.'"><br />';
echo '<input name="salt" type="text" size="20" value="'.$salt.'"> (pour md5 salt perso)<br />';
echo '<input type="submit" name="Submit" value="Confirmer"></form>';
if (CRYPT_STD_DES == 1) {
echo '<b>Standard DES</b><br />'.$user.':'.crypt($pass, $salt).'<br />';
}
if (CRYPT_EXT_DES == 1) {
echo '<b>Extended DES</b><br />'.$user.':'.crypt($pass, $salt).'<br />';
}
if (CRYPT_MD5 == 1) {
echo '<b>crypt md5</b><br />'.$user.':'.crypt($pass).'<br />';
echo '<b>crypt md5 et salt perso</b><br />'.$user.':'.crypt($pass, '$1$'.$salt.'$').'<br />';
}
Tu ne dois rien paramétrer. Le salt est contenu dans le mot de passe crypté comme tu peux le voir dans mon post plus haut.Le problème, c'est que quand je m'identifie, on ne me demande qu'un pseudo et un mot de passe, rien d'autre : si j'utilise un grain de sel pour crypter, comment est-ce que je dois faire pour le paramétrer dans mon .htaccess pour que la vérification utilise le même ? C'est en fait surtout ça que je cherche.
À moins que.... faut que je fasse un autre test...
Aucun des trois ne fonctionne.Standard DES
Cyrano:beeoPwPUZdxNk
crypt md5
Cyrano:$1$BA..095.$xFU1STOGZFyg.gNt4r26R0
crypt md5 et salt perso
Cyrano:$1$bergerac$ksQ2280tsfI/LDNdQ.WRi.
La différence majeure que je vois est au niveau de la première partie entre les $$ ainsi que la seconde. htpasswd.exe utilise un salt aléatoire peut-être basé sur une variable de timestamp ou quelque chose dans ce goût-là, aucune idée.Cyrano:$apr1$JA2.....$tpjb8Ux.0Owqz9djjH4tX0
Code : Tout sélectionner
Usage:
htpasswd [-cmdpsD] passwordfile username
htpasswd -b[cmdpsD] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file.
-n Don't update file; display results on stdout.
-m Force MD5 encryption of the password (default).
-d Force CRYPT encryption of the password.
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it.
-D Delete the specified user.
On Windows, NetWare and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.
Cela n'explique pas pourquoi crypt() de PHP ne fonctionne pas. Tous les pseudo:mdp que tu donnes là-haut fonctionnent chez moi. Si tu fais tes tests en local, essaye chez ton hébérgeur (ou l'inverse).htpasswd encrypts passwords using either a version of MD5
modified for Apache, or the system's crypt() routine. Files
managed by htpasswd may contain both types of passwords;
some user records may have MD5-encrypted passwords while
others in the same file may have passwords encrypted with
crypt().
Ha... ben ça, il y a des chances pour que ça fasse pas mal avancer le schmilblick : ça veut dire qu'il y a une m**** dans ma configuration de serveur Apache.... Tous les pseudo:mdp que tu donnes là-haut fonctionnent chez moi. ...
Loaded Modules : core mod_win32 mpm_winnt http_core mod_so mod_access mod_actions mod_alias mod_asis mod_auth mod_autoindex mod_cgi mod_dir mod_env mod_imap mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_rewrite mod_setenvif mod_userdir mod_php5
D'autres extraits de la page man de htpasswd qui pourraient t'intéresser:Though htpasswd will support creation on all platforms, the httpd daemon will only accept plain text passwords on Windows, Netware and TPF.
Relis la dernière phrase, c'est peut-être une piste.If executed on a Windows system, the password will be encrypted using the modified Apache MD5 algorithm; otherwise, the system's crypt() routine will be used. If the file does not exist, htpasswd will do nothing except return an error.
-m
Use MD5 encryption for passwords. On Windows, Netware and TPF, this is the default.
-d
Use crypt() encryption for passwords. The default on all platforms but Windows, Netware and TPF. Though possibly supported by htpasswd on all platforms, it is not supported by the httpd server on Windows, Netware and TPF.