title: Hash meta:

  • name: description content: Used to quickly process hash passwords and data integrity check scenarios.
  • name: keywords content: swoole|swoole extension|swoole framework|Easyswoole|Component Library|Miscellaneous Tools|Hash

Hash

Use

Used to quickly process hash passwords and data integrity check scenarios

Core Object Class

To implement this component function you need to load the core class:

  1. EasySwoole\Utility\Hash

Core Object Method

makePasswordHash

Produce a hash from a plaintext value

  • mixed $value needs to produce the original text of the hash
  • mixed $cost recursive layers
  1. Static function makePasswordHash($value, $cost = 10)

validatePasswordHash

Check if the plaintext value matches the hash

  • mixed $value
  • mixed $cost hash encrypted
    1. static function validatePasswordHash($value, $hashValue)

How to use

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: root
  5. * Date: 19-1-9
  6. * Time: 10:10
  7. */
  8. require './vendor/autoload.php';
  9. $password = 123456;
  10. $hash = \EasySwoole\Utility\Hash::makePasswordHash($password);
  11. var_dump($hash);
  12. var_dump(\EasySwoole\Utility\Hash::validatePasswordHash($password, $hash));
  13. /**
  14. * Output results:
  15. * string(60) "$2y$10$ESx0z8TGSJpMI3Hgr6nJJOdbretS2TBqv4d5L0XjlTkSjSiCiq/f6"
  16. * bool(true)
  17. */