Skip to content

Commit

Permalink
Merge pull request #1036 from glensc/randomlib-deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Apr 1, 2021
2 parents 3fded52 + 0917cc5 commit f8b3013
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ See [Upgrading] for details on how to upgrade.
- Use logger via Symfony container, #1029
- Fix twig deprecation, #1038
- Fix markdown `heading_permalink` deprecation, #1037
- Use `random_bytes()` rather RandomLib library, #1036

[3.10.2]: https://github.com/eventum/eventum/compare/v3.10.1...master

Expand Down
2 changes: 1 addition & 1 deletion lib/eventum/class.auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function privateKey(): string
public static function generatePrivateKey(): void
{
$path = Setup::getPrivateKeyPath();
$private_key = md5(Misc::generateRandom(32));
$private_key = md5(random_bytes(32));

$contents = '<' . "?php\n\$private_key = " . var_export($private_key, 1) . ";\n";

Expand Down
5 changes: 1 addition & 4 deletions lib/eventum/class.misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,7 @@ public static function htmlentities($var): string
*/
public static function generateRandom($size = 32)
{
$factory = new RandomLib\Factory();
$generator = @$factory->getMediumStrengthGenerator();

return $generator->generate($size);
return random_bytes($size);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Mail/MessageIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

namespace Eventum\Mail;

use Misc;

class MessageIdGenerator
{
/** @var string */
Expand All @@ -36,7 +34,7 @@ public function generate(): string
$first = microtime(true);

// second part is random string
$second = bin2hex(Misc::generateRandom(16));
$second = bin2hex(random_bytes(16));

return $this->format($first, $second);
}
Expand Down

0 comments on commit f8b3013

Please sign in to comment.