$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
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.