Skip to content

Commit

Permalink
Use default length of 64 for Security::randomString().
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Feb 1, 2018
1 parent 71a715f commit 8361b3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Utility/Security.php
Expand Up @@ -136,11 +136,11 @@ public static function randomBytes($length)
/**
* 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))),
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Utility/SecurityTest.php
Expand Up @@ -344,7 +344,7 @@ public function testRandomString()
$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');
Expand Down

0 comments on commit 8361b3a

Please sign in to comment.