Skip to content

Commit c374f5f

Browse files
committed
Update Password.php
1 parent d1d4eff commit c374f5f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Security/Password.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,19 @@ final class Password
3333
* @param bool $special
3434
* @return string
3535
*/
36-
public static function generate(int $length = self::LENGTH, bool $special = true) : string
36+
public static function generate(int $length = self::LENGTH, bool $special = false) : string
3737
{
38-
return Tokenizer::generate($length, $special);
38+
$token = '';
39+
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
40+
$chars .= 'abcdefghijklmnopqrstuvwxyz';
41+
$chars .= '0123456789';
42+
if ( $special ) {
43+
$chars .= '!#$%&()*+,-.:;<>?@[]^{}~';
44+
}
45+
for ($i = 0; $i < $length; $i++) {
46+
$token .= $chars[Tokenizer::range(0, strlen($chars))];
47+
}
48+
return $token;
3949
}
4050

4151
/**

0 commit comments

Comments
 (0)