PHP Classes

File: php/securePasssword.php

Recommend this page to a friend!
  Classes of bamigboye biodun   Logical Functions   php/securePasssword.php   Download  
File: php/securePasssword.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Logical Functions
General-purpose PHP and JavaScript functions
Author: By
Last change:
Date: 2 years ago
Size: 946 bytes


Class file image Download
function securePassword($userPassword, $savedPassword=true) {

$hash = password_hash($userPassword, PASSWORD_BCRYPT);

is_bool($savedPassword) ? $hash : password_verify($userPassword,$savedPassword);

Author Biodun Bamigboye

Description :
A basic function to securely hash and confirm password in php programming language
If first argument is passed it hash the password and return the hash value,
if plain user password is passed as first argument and the saved hash is passed as second argument
it compares and return true or false
 usage case 1 :
return value : $2y$10$mlbam8RbSg60EvHkwAoavu/nKKrg/otuNl457RxWkhbZOqBKebw.2

Usage case 2 :

return value : true

usage case 3 :

return value : false