Strict ISecure random
* Declare strict * Scalar arguments * Return type * Use fully qualified name for strlen Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
60f38d37fe
commit
de5d7aa331
|
@ -21,6 +21,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OC\Security;
|
||||
|
||||
use OCP\Security\ISecureRandom;
|
||||
|
@ -70,9 +72,9 @@ class SecureRandom implements ISecureRandom {
|
|||
* specified all valid base64 characters are used.
|
||||
* @return string
|
||||
*/
|
||||
public function generate($length,
|
||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/') {
|
||||
$maxCharIndex = strlen($characters) - 1;
|
||||
public function generate(int $length,
|
||||
string $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'): string {
|
||||
$maxCharIndex = \strlen($characters) - 1;
|
||||
$randomString = '';
|
||||
|
||||
while($length > 0) {
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCP\Security;
|
||||
|
||||
/**
|
||||
|
@ -87,7 +89,7 @@ interface ISecureRandom {
|
|||
* @return string
|
||||
* @since 8.0.0
|
||||
*/
|
||||
public function generate($length,
|
||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
|
||||
public function generate(int $length,
|
||||
string $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'): string;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue