Laravel hash equivalent in main php

I already have a web application in which I encrypted my entire password using

Hash :: brand ($ string);

Which is equivalent to what is in core php, which will help my Android developers in sync with my application. I tried using a hash and a crypt, it was not the same. Help me with this to make it easier for developers to write a backend.

+6
source share
2 answers

Try using

password_hash ($ string);

you can check it using

password_verify ($ string, $ hash);

Hope this helps!

+3
source

I assume the Illuminate\Hashing\BcryptHasher::make() method. You can check the source of this class to see what happens:

 <?php namespace Illuminate\Hashing; class BcryptHasher implements HasherInterface { protected $rounds = 10; public function make($value, array $options = array()) { $cost = isset($options['rounds']) ? $options['rounds'] : $this->rounds; $hash = password_hash($value, PASSWORD_BCRYPT, array('cost' => $cost)); if ($hash === false) { throw new \RuntimeException("Bcrypt hashing not supported."); } return $hash; } 

So, to do this basically PHP, you need to do something like:

 $string = "some string that needs to be hashed"; $hash = password_hash($string, PASSWORD_BCRYPT, array('cost' => 10)); 
+2
source

Source: https://habr.com/ru/post/972488/


All Articles