Welcome Guest, Not a member yet? Register   Sign In
Using the PASSWORD() function
#8

Hi, it's supposed to be like this. And only after you have successfully converted everyone's password with password_hash.
passwordConverted = 1;
PHP Code:
if (password_verify($this->input->post('jbsPassword'), $data['userData']['lc_password'])) {
 
   echo 'Password is valid!';
} else {
 
   echo 'Invalid password.';


Validate passwords as of now:
passwordConverted = 0;
PHP Code:
function mysql_password($string){
 
   $pass strtoupper(
 
           sha1(
 
                   sha1($stringtrue)
 
           )
 
   );
 
   $pass '*' $pass;
 
   return $pass;
}

if (
mysql_password($this->input->post('jbsPassword') === $data['userData']['lc_password']) {
 
   echo 'Password is valid!';
 
   echo 'Convert password now!';
 
   $newPassword password_hash($this->input->post('jbsPassword'),PASSWORD_DEFAULT);
 
   // Save in DB
} else {
 
   echo 'Invalid password.';



If you rehash every password in the database:
passwordConverted = 0 AND password_hash have been looped thru on ALL passwords already.

PHP Code:
function mysql_password($string){
 
   $pass strtoupper(
 
           sha1(
 
                   sha1($stringtrue)
 
           )
 
   );
 
   $pass '*' $pass;
 
   return $pass;
}

if (
password_verify(mysql_password($this->input->post('jbsPassword')), $data['userData']['lc_password'])) {
 
   echo 'Password is valid!';
 
   echo 'Convert password now!';
 
   $newPassword password_hash($this->input->post('jbsPassword'),PASSWORD_DEFAULT);
 
   // Save in DB
} else {
 
   echo 'Invalid password.';

Reply


Messages In This Thread
Using the PASSWORD() function - by barrypoore - 03-28-2018, 01:29 PM
RE: Using the PASSWORD() function - by jreklund - 03-28-2018, 02:24 PM
RE: Using the PASSWORD() function - by barrypoore - 03-28-2018, 02:49 PM
RE: Using the PASSWORD() function - by jreklund - 03-29-2018, 03:04 AM
RE: Using the PASSWORD() function - by barrypoore - 04-09-2018, 11:40 AM
RE: Using the PASSWORD() function - by jreklund - 04-09-2018, 12:50 PM
RE: Using the PASSWORD() function - by barrypoore - 04-09-2018, 01:44 PM
RE: Using the PASSWORD() function - by jreklund - 04-09-2018, 02:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB