aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-01-14 21:05:19 +0100
committerGitHub <noreply@github.com>2018-01-14 21:05:19 +0100
commitfcea6e1564c7189949b0b88f696e16e2979738fa (patch)
treed73df5e9caf250162b88054be751964090e0b929 /lib
parent7d9146db38be09dc413282aa217ebc0003c99d3d (diff)
parent6e1ee1e7a7aa6e52b922665b9466ce2db244ecb6 (diff)
downloadnextcloud-server-fcea6e1564c7189949b0b88f696e16e2979738fa.tar.gz
nextcloud-server-fcea6e1564c7189949b0b88f696e16e2979738fa.zip
Merge pull request #7849 from nextcloud/strict_securerandom
Strict ISecure random
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Security/SecureRandom.php7
-rw-r--r--lib/public/Security/ISecureRandom.php5
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/private/Security/SecureRandom.php b/lib/private/Security/SecureRandom.php
index 5bd909ea002..75d9d02a1d3 100644
--- a/lib/private/Security/SecureRandom.php
+++ b/lib/private/Security/SecureRandom.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -70,9 +71,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) {
diff --git a/lib/public/Security/ISecureRandom.php b/lib/public/Security/ISecureRandom.php
index 76e207fbbd8..235b3033c44 100644
--- a/lib/public/Security/ISecureRandom.php
+++ b/lib/public/Security/ISecureRandom.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -87,7 +88,7 @@ interface ISecureRandom {
* @return string
* @since 8.0.0
*/
- public function generate($length,
- $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
+ public function generate(int $length,
+ string $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'): string;
}