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;
|
namespace OC\Security;
|
||||||
|
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
|
@ -70,9 +72,9 @@ class SecureRandom implements ISecureRandom {
|
||||||
* specified all valid base64 characters are used.
|
* specified all valid base64 characters are used.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function generate($length,
|
public function generate(int $length,
|
||||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/') {
|
string $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'): string {
|
||||||
$maxCharIndex = strlen($characters) - 1;
|
$maxCharIndex = \strlen($characters) - 1;
|
||||||
$randomString = '';
|
$randomString = '';
|
||||||
|
|
||||||
while($length > 0) {
|
while($length > 0) {
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCP\Security;
|
namespace OCP\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,7 +89,7 @@ interface ISecureRandom {
|
||||||
* @return string
|
* @return string
|
||||||
* @since 8.0.0
|
* @since 8.0.0
|
||||||
*/
|
*/
|
||||||
public function generate($length,
|
public function generate(int $length,
|
||||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
|
string $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'): string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue