3
validatedbpassword
validate_db_password
SYNOPSIS
validate_db_password($s)
DESCRIPTION
validate_db_password
returns true
if $s
is a secure password for a DB connector, otherwise false
.
CODE
- function validate_db_password($s) {
- $charset = array('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz', '0123456789', '~!@#$%^&*()_-+={}[]/<>,.;?:|');
- if (strlen($s) < 10) {
- return false;
- }
- foreach ($charset as $chars) {
- if (preg_match_all('/[' . preg_quote($chars, '/') . ']/', $s) < 2) {
- return false;
- }
- }
- return true;
- }
Comments