Skip to content

Commit

Permalink
Dissallow certain special chars - some PHP Projects do not support sp…
Browse files Browse the repository at this point in the history
…ecial chars for Passwords. Wordpress for Example does not allow the Backslash \ - so I wrote the method blacklistSymbol
  • Loading branch information
Michael Schmitt committed Feb 24, 2016
1 parent 71f6b10 commit df7d22c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions PWGen.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,25 @@ private static function __static() {
}
}

/**
* Disallow certain special chars
* @param array $symbols
*/
public function blacklistSymbol(array $symbols )
{
foreach ($symbols as $symbol) {
if (!preg_match('/' . preg_quote($symbol) . '/', self::$pw_symbols)) {
return;
}
}
$symbolArray = str_split(self::$pw_symbols);
foreach ($symbols as $symbol) {
$index =array_search($symbol, $symbolArray);
unset($symbolArray[$index]);
}
self::$pw_symbols = implode('', $symbolArray);
}

/**
* Returns the last generated password. If there is none, a new one will be generated.
*/
Expand Down

0 comments on commit df7d22c

Please sign in to comment.