Browse Source

Use default length of 64 for Security::randomString().

ADmad 8 years ago
parent
commit
8361b3a36a
2 changed files with 3 additions and 3 deletions
  1. 2 2
      src/Utility/Security.php
  2. 1 1
      tests/TestCase/Utility/SecurityTest.php

+ 2 - 2
src/Utility/Security.php

@@ -136,11 +136,11 @@ class Security
     /**
      * Creates a secure random string.
      *
-     * @param int $length String length
+     * @param int $length String length. Default 64.
      * @return string
      * @since 3.6.0
      */
-    public static function randomString($length)
+    public static function randomString($length = 64)
     {
         return substr(
             bin2hex(Security::randomBytes(ceil($length / 2))),

+ 1 - 1
tests/TestCase/Utility/SecurityTest.php

@@ -344,7 +344,7 @@ class SecurityTest extends TestCase
         $value = Security::randomString(7);
         $this->assertSame(7, strlen($value));
 
-        $value = Security::randomString(64);
+        $value = Security::randomString();
         $this->assertSame(64, strlen($value));
 
         $this->assertRegExp('/^[0-9a-f]+$/', $value, 'should return a ASCII string');