$str="plus2net.com";
$str_hash=password_hash($str,PASSWORD_DEFAULT);
echo $str_hash;
Output is here $2y$10$/r1bsR9lXZ52gYPmeH69Bu3.k0ABji7ZJdiZTPmUWEAgaQpkBkfKq
Syntax
password_hash('$string',$alog,$options);
| Parameter | DESCRIPTION |
|---|---|
| $string | Required : Input password string variable |
| $alog | Required : algorithms to be used. |
| $options | Optional : An associative array containing options. |
salt : has to be minimum 22 char length. If not given then default salt will be used. Salt option is removed in PHP 7.0 so better not to use salt and allow PHP to use default salt. cost : default value 10 .This is the algorithm cost which depends on hardware.
$str="plus2net.com";
$options =array('cost' => 12,'salt'=>'my_salt_of_22_legth_ok');
$str_hash=password_hash($str,PASSWORD_DEFAULT,$options);
echo $str_hash;
Output is here
$2y$12$bXlfc2FsdF9vZl8yMl9sZOXWXRIfffjBg.Qk195t1LcqrI2JBjIUW
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.