diff --git a/lib/private/Security/SecureRandom.php b/lib/private/Security/SecureRandom.php
index 5bd909ea002f9a0fd4b35f8b25b14456bce03a70..b5270d08b4698b619891fe76776550ad819c172d 100644
--- a/lib/private/Security/SecureRandom.php
+++ b/lib/private/Security/SecureRandom.php
@@ -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) {
diff --git a/lib/public/Security/ISecureRandom.php b/lib/public/Security/ISecureRandom.php
index 76e207fbbd8d64279ada36160099116c7a8be859..14976831a1ab73202702dd4ed050c0e16baae1be 100644
--- a/lib/public/Security/ISecureRandom.php
+++ b/lib/public/Security/ISecureRandom.php
@@ -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;
 
 }