meteor’s module for encrypting user passwords is under accounts-password:
https://github.com/meteor/meteor/blob/5931bcdae362e1026ceb8a08e5a4b053ce5340b7/packages/accounts-password/password_server.js
By analysis, meteor encrypted user When entering a password, first perform a SHA256 calculation on the password, and then encrypt it with bcrypt. The obtained string is written into the users table services.password.bcrypt.
Knowing the above algorithm, it is easy to write code with consistent effects through php.
php The bcrypt encryption extension document is at http://cn2.php.net/manual/zh/book.password.php
Final code:
public function password_hash($password){ return password_hash(hash('sha256', $password), PASSWORD_BCRYPT, ['salt'=>mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)]); }
public function password_compare($inputpassword, $hash){ return password_verify(hash('sha256', $inputpassword), $hash); }
The above introduces the Meteor user login registration password verification php version, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.