Created
May 22, 2023 17:32
-
-
Save lucasgio/eac45d2845342acdb84b346a9c48b356 to your computer and use it in GitHub Desktop.
Password Strenght
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
class PasswordCheckTrait | |
{ | |
public static function check(string $password) | |
{ | |
$uppercase = preg_match('@[A-Z]@', $password); | |
$lowercase = preg_match('@[a-z]@', $password); | |
$number = preg_match('@[0-9]@', $password); | |
$specialChars = preg_match('@[^\w]@', $password); | |
if (!$uppercase || !$lowercase || !$number || !$specialChars || strlen($password) < 8) { | |
return 'La contraseña debe tener al menos 8 caracteres e incluir como mínimo una letra mayúscula, un número y un carácter especial..'; | |
} | |
return null; | |
} | |
public static function convertHash(string $password) | |
{ | |
return hash('md5',$password); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment