Skip to content

Commit

Permalink
Merge pull request #133 from gsteel/drop-math
Browse files Browse the repository at this point in the history
Drop `Laminas\Math` dependency
  • Loading branch information
Ocramius authored Jun 14, 2022
2 parents 90acc89 + afed936 commit ba665f5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 68 deletions.
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"laminas/laminas-filter": "^2.14.0",
"laminas/laminas-http": "^2.14.2",
"laminas/laminas-i18n": "^2.15.0",
"laminas/laminas-math": "^2.7.1",
"laminas/laminas-session": "^2.12.1",
"laminas/laminas-uri": "^2.9.1",
"phpspec/prophecy-phpunit": "^2.0",
Expand All @@ -58,7 +57,6 @@
"laminas/laminas-filter": "Laminas\\Filter component, required by the Digits validator",
"laminas/laminas-i18n": "Laminas\\I18n component to allow translation of validation error messages",
"laminas/laminas-i18n-resources": "Translations of validator messages",
"laminas/laminas-math": "Laminas\\Math component, required by the Csrf validator",
"laminas/laminas-servicemanager": "Laminas\\ServiceManager component to allow using the ValidatorPluginManager and validator chains",
"laminas/laminas-session": "Laminas\\Session component, ^2.8; required by the Csrf validator",
"laminas/laminas-uri": "Laminas\\Uri component, required by the Uri and Sitemap\\Loc validators",
Expand Down
64 changes: 1 addition & 63 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/Csrf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Laminas\Validator;

use Laminas\Math\Rand;
use Laminas\Session\Container as SessionContainer;
use Laminas\Stdlib\ArrayUtils;
use Traversable;
Expand All @@ -11,6 +10,7 @@
use function is_array;
use function is_string;
use function md5;
use function random_bytes;
use function sprintf;
use function str_replace;
use function strtolower;
Expand Down Expand Up @@ -301,7 +301,7 @@ protected function initCsrfToken()
*/
protected function generateHash()
{
$token = md5($this->getSalt() . Rand::getBytes(32) . $this->getName());
$token = md5($this->getSalt() . random_bytes(32) . $this->getName());

$this->hash = $this->formatHash($token, $this->generateTokenId());

Expand All @@ -314,7 +314,7 @@ protected function generateHash()
*/
protected function generateTokenId()
{
return md5(Rand::getBytes(32));
return md5(random_bytes(32));
}

/**
Expand Down

0 comments on commit ba665f5

Please sign in to comment.