Home > Backend Development > PHP Tutorial > Meteor user login registration password verification php version

Meteor user login registration password verification php version

WBOY
Release: 2016-07-29 09:01:14
Original
1047 people have browsed it

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)]);
    }
Copy after login
    public function password_compare($inputpassword, $hash){
        return password_verify(hash('sha256', $inputpassword), $hash);
    }
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template