Skip to content
This repository has been archived by the owner on May 18, 2020. It is now read-only.

Commit

Permalink
Remove mcrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbrouwers committed Sep 3, 2018
1 parent 96bc91e commit 8aa702b
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions src/Services/CodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,11 @@

class CodeGenerator
{

/**
* @var string
*/
private static $hashing = 'sha256';

/**
* @return string
*/
public static function make()
{
return hash(static::$hashing, self::generateEntropy());
}

/**
* @return string
*/
public static function generateEntropy()
{
$entropy = mcrypt_create_iv(32, self::getRandomizer());
$entropy .= uniqid(mt_rand(), true);

return $entropy;
}

/**
* @return int
*/
protected static function getRandomizer()
{
if (defined('MCRYPT_DEV_URANDOM')) {
return MCRYPT_DEV_URANDOM;
}
if (defined('MCRYPT_DEV_RANDOM')) {
return MCRYPT_DEV_RANDOM;
}
mt_srand();

return MCRYPT_RAND;
return str_random(32);
}
}

0 comments on commit 8aa702b

Please sign in to comment.