zoukankan      html  css  js  c++  java
  • HelpersPassword

    HelpersPassword

    The password class uses php 5 password_ functions.

    To create a hash of a password, call the make method and provide the password to be hashed, once done save the $hash.

    $hash = Password::make($password);

    When logging in a user their hash must be retrieved from the database and compared against the provided password to make sure they match, for this a method called password_verify is used, it has 2 parameters the first is the user provided password the second is the hash from the database.

        if (Password::verify($_POST['password'], $data[0]->password)) {
         //passed
        } else {
         //failed
        }

    From time to time you may update your hashing parameters (algorithm, cost, etc). So a function to determine if rehashing is necessary is available:

    if (Password::verify($password, $hash)) {     
       if (Password::needsRehash($hash, $algorithm, $options)) {         
        $hash = Password::make($password, $algorithm, $options); /* Store new hash in db */     
       } 
    }
  • 相关阅读:
    c#数据类型
    遮罩层
    图片轮播
    js 获取浏览器高度和宽度值
    bootstrap、jquery
    洛谷P1442 铁球落地 题解
    HDU3016 Man Down 题解
    POJ2892 Tunnel Warfare 题解
    HDU2795 Billboard 题解
    CF920F SUM and REPLACE 题解
  • 原文地址:https://www.cnblogs.com/chunguang/p/5643189.html
Copyright © 2011-2022 走看看