passwords - PHP password_hash error -
i have been trying understand password salting , hashing project working on. responses previous question saw php manual password_hash way start.
however, when trying out code on page, error haven't been able resolve.
code:
<?php /** * note salt here randomly generated. * never use static salt or 1 not randomly generated. * * vast majority of use-cases, let password_hash generate salt randomly */ $options = [ 'cost' => 11, 'salt' => mcrypt_create_iv(22, mcrypt_dev_urandom), ]; echo password_hash("rasmuslerdorf", password_bcrypt, $options)."\n"; ?>
error:
parse error: syntax error, unexpected '[' in /home/content/##/######/html/testingfolder/hashnsalt.php on line 8
according manual -
the above example output: $2y$11$q5mkhsbtlsjcnevsyh64a.acluzhngog7tqakvmqwo9c8xb.t89f.
line 8
$options = [
can here explain why getting error - since have copied , pasted test page php manual itself? still in stages of learning authentication/ php etc , depend on manual, stackexchange/overflow understand why things don't work way should. totally stumped when code find in manual doesn't work way should!
not security issue, syntax one.
the short array syntax:
$options = [ ... ];
is php 5.4 feature... had array( ... )
.
you don't have 5.4 installed. password_hash
php 5.5 feature you'll need update php version.
Comments
Post a Comment