Comment WordPress crypte le mot de passe?
-
-
Enfermant ceci comme un double de la question @SharkTheDark aen fait la capacité d'accepter des réponses à ...Closing this as a duplicate of the question @SharkTheDark actually has the ability to accept answers to ...
- 0
- 2011-10-25
- EAMann
-
vousferiezmieux de vérifiericipourplus d'informations.http://www.kvcodes.com/2016/09/wordpress-password-hash-generator/you better check here for more informations. http://www.kvcodes.com/2016/09/wordpress-password-hash-generator/
- 0
- 2016-09-17
- Kvvaradha
-
3 réponses
- votes
-
- 2011-10-24
Labibliothèque de chiffrement desmots depasse setrouve dans/wp-includes/class-phpass.php.Il s'agit du cadre de hachage demot depasse PHPportable .
The password encryption library is in /wp-includes/class-phpass.php. It is the Portable PHP Password hashing framework.
-
Pouvez-vous écrire quelquesexemples comment l'utiliser? Comme c'est ànouveau WP Plugin,pas clair PHP commeje l'ai demandé,mais si vouspouvez écrire comment l'utiliser à l'intérieur de PHP,ce sera utile ...Can you write some samples how to use it? Since it's WP Plugin again, not clear PHP as I asked, but if you can write how to use it inside PHP it will be useful...
- 0
- 2011-10-24
- SharkTheDark
-
Cen'estpas unplugin WordPress.Il s'agit d'unfichier de classe PHP standardinclus avec leframework WordPress.Il vous suffit de l'inclure dans unnouveaufichier PHP,de créer uneinstanceet de l'utiliser.This isn't a WordPress plugin. This is a standard PHP class file that is included with the WordPress framework. You just include it in a new PHP file, create an instance, and use it.
- 1
- 2011-10-24
- John Watson
-
- 2011-10-24
Il semble que vous souhaitiez utiliser du codeexternepour valider lesnoms d'utilisateur/mots depassepar rapport à labase de données de WP. Si c'estexact,vous allezpasserbeaucoup detemps à réinventer la roue. Maispour unbonexemple de lafaçon defaire celaen utilisant PHP simple,c'est unebonneidée dejeter un œil auxfonctions WP debase qui lefont déjà.
Exemple concret,`wp_check_password () ':
function wp_check_password($password, $hash, $user_id = '') { global $wp_hasher; // If the hash is still md5... if ( strlen($hash) <= 32 ) { $check = ( $hash == md5($password) ); if ( $check && $user_id ) { // Rehash using new hash. wp_set_password($password, $user_id); $hash = wp_hash_password($password); } return apply_filters('check_password', $check, $password, $hash, $user_id); } // If the stored hash is longer than an MD5, presume the // new style phpass portable hash. if ( empty($wp_hasher) ) { require_once ( ABSPATH . 'wp-includes/class-phpass.php'); // By default, use the portable hash from phpass $wp_hasher = new PasswordHash(8, TRUE); } $check = $wp_hasher->CheckPassword($password, $hash); return apply_filters('check_password', $check, $password, $hash, $user_id); }
Tout d'abord,WordPress vérifie si lemot depasse haché de l'utilisateur utilisetoujours le MD5 old-schoolpour la sécurité. Celapermet depréserver la compatibilité ascendante desmises àjour. Si lemot depasse est MD5,WordPress le remplacera automatiquementpar unnouveau hachageen utilisant lenouveau système (l'appel à
wp_set_password()
). Si cen'est pas MD5,WPpasse à lanouvelle configuration de hachage.Tout d'abord,nousincluons le Portable PHP Hashing Framework (déjàmentionnépar @John Watson dans une autre réponse)et en créons uneinstance,en le stockant dans la variableglobale
$wp_hasher
.Noustransmettonsensuite lemot depasseen texte clairet le hachagepour le vérifier,en utilisant laméthode
CheckPassword()
de labibliothèque.Si vous souhaitez l'utiliser dans unebibliothèqueexterne,vous devrez d'abord
include
/require
labibliothèque,puis l'instancier,puistransmettre votretextebrutmot depasseet son hachage. Donc,quelques untested psuedo-code ...function validate_password( $plaintext, $hash ) { require_once( 'class-phpass.php' ); $hasher = new PasswordHash(8, TRUE); return $hasher->CheckPassword( $plaintext, $hash ); }
It sounds like you want to use external code to validate usernames/passwords against WP's database. If that's correct, you're going to spend a lot of time reinventing the wheel. But for a good example of how to do this using straight PHP, it's a good idea to take a look at the core WP functions that already do it.
Case in point, `wp_check_password()':
function wp_check_password($password, $hash, $user_id = '') { global $wp_hasher; // If the hash is still md5... if ( strlen($hash) <= 32 ) { $check = ( $hash == md5($password) ); if ( $check && $user_id ) { // Rehash using new hash. wp_set_password($password, $user_id); $hash = wp_hash_password($password); } return apply_filters('check_password', $check, $password, $hash, $user_id); } // If the stored hash is longer than an MD5, presume the // new style phpass portable hash. if ( empty($wp_hasher) ) { require_once ( ABSPATH . 'wp-includes/class-phpass.php'); // By default, use the portable hash from phpass $wp_hasher = new PasswordHash(8, TRUE); } $check = $wp_hasher->CheckPassword($password, $hash); return apply_filters('check_password', $check, $password, $hash, $user_id); }
First, WordPress checks to see if the user's hashed password is still using old-school MD5 for security. This is to preserve backwards compatibility for updates. If the password is MD5, then WordPress will automatically replace it with a new hash using the new system (the call to
wp_set_password()
). If it isn't MD5, then WP moves on to the newer hashing setup.First, we include the Portable PHP Hashing Framework (already mentioned by @John Watson in another answer) and create an instance of it, storing it in the global
$wp_hasher
variable.We then pass in the plaintext password and the hash to verify it against, using the
CheckPassword()
method of the library.If you want to use this in an external library, you'll have to first
include
/require
the library, then instantiate it, then pass in your plain text password and its hash. So some untested psuedo-code ...function validate_password( $plaintext, $hash ) { require_once( 'class-phpass.php' ); $hasher = new PasswordHash(8, TRUE); return $hasher->CheckPassword( $plaintext, $hash ); }
-
- 2011-10-24
require_once( '/path/to/wp-includes/class-phpass.php' ); $wp_hasher = new PasswordHash( 8, TRUE ); $password = 'swordfish'; $hashed_password = $wp_hasher->HashPassword( $password );
require_once( '/path/to/wp-includes/class-phpass.php' ); $wp_hasher = new PasswordHash( 8, TRUE ); $password = 'swordfish'; $hashed_password = $wp_hasher->HashPassword( $password );
-
Est-ilpossible de hacher également lemot depasse de lapageprotégée dans labase de données?It it possible to hash also the password of protected page in database?
- 0
- 2018-01-31
- sampaii
Jetravaille avec un site quiestfait avec WordPress,et je dois ajouter certainesparties qui sonten dehors de WP,et vérifier la connexion de l'utilisateur,maisje nepeuxpastrouver comment WP crypte lemot depasse avant de l'écrire dans DB...
J'aiessayé avecmd5mais cen'estpas le cas ...
Est-ce que quelqu'un sait comment vérifier lemot depasseen dehors de WP,sans utiliser sespluggins/checkers,effacer le code PHP?