@@ -2299,6 +2299,20 @@ function pla_password_hash($password_clear,$enc_type) {
2299
2299
2300
2300
break ;
2301
2301
2302
+ case 'argon2i ' :
2303
+ if (! defined ('PASSWORD_ARGON2I ' ))
2304
+ error (_ ('Your system does not support argon2i encryption (PHP 7.2 or upper is required). ' ),'error ' ,'index.php ' );
2305
+ $ new_value = sprintf ('{ARGON2}%s ' ,password_hash ($ password_clear ,PASSWORD_ARGON2I ));
2306
+
2307
+ break ;
2308
+
2309
+ case 'argon2id ' :
2310
+ if (! defined ('PASSWORD_ARGON2ID ' ))
2311
+ error (_ ('Your system does not support argon2id encryption (PHP 7.3 or upper is required). ' ),'error ' ,'index.php ' );
2312
+ $ new_value = sprintf ('{ARGON2}%s ' ,password_hash ($ password_clear ,PASSWORD_ARGON2ID ));
2313
+
2314
+ break ;
2315
+
2302
2316
case 'clear ' :
2303
2317
default :
2304
2318
$ new_value = $ password_clear ;
@@ -2534,6 +2548,14 @@ function password_check($cryptedpassword,$plainpassword,$attribute='userpassword
2534
2548
2535
2549
break ;
2536
2550
2551
+ # Argon2 crypted passwords
2552
+ case 'argon2 ' :
2553
+ if (password_verify ($ plainpassword , $ cryptedpassword ))
2554
+ return true ;
2555
+ else
2556
+ return false ;
2557
+ break ;
2558
+
2537
2559
# No crypt is given assume plaintext passwords are used
2538
2560
default :
2539
2561
if ($ plainpassword == $ cryptedpassword )
@@ -2577,6 +2599,16 @@ function get_enc_type($user_password) {
2577
2599
2578
2600
elseif (preg_match ('/{[^}]+}_+/ ' ,$ user_password ))
2579
2601
$ enc_type = 'ext_des ' ;
2602
+
2603
+ }
2604
+ elseif (strcasecmp ($ enc_type ,'argon2 ' ) == 0 ) {
2605
+
2606
+ if (preg_match ('/{ARGON2}\$argon2i\$/ ' ,$ user_password ))
2607
+ $ enc_type = 'argon2i ' ;
2608
+
2609
+ elseif (preg_match ('/{ARGON2}\$argon2id\$/ ' ,$ user_password ))
2610
+ $ enc_type = 'argon2id ' ;
2611
+
2580
2612
}
2581
2613
2582
2614
return $ enc_type ;
0 commit comments