change random string library because of deprecated code in old one

This commit is contained in:
Daniel Seifert 2019-08-05 21:42:26 +02:00
parent 2fb7e63788
commit d20322867d
3 changed files with 29 additions and 4 deletions

View File

@ -35,7 +35,7 @@
"oxid-esales/oxideshop-metapackage-ce": "~6.0.3 || ~6.1.0",
"spomky-labs/otphp": "^8.3",
"bacon/bacon-qr-code": "^1.0",
"ircmaxell/random-lib": "^1.2"
"zendframework/zend-math": "^3.2"
},
"autoload": {
"psr-4": {

View File

@ -0,0 +1,27 @@
<?php
namespace D3\Totp\Application\Model;
use Zend\Math\Rand;
class d3RandomGenerator extends Rand
{
const CHAR_UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const CHAR_LOWER = 'abcdefghijklmnopqrstuvwxyz';
const CHAR_DIGITS = '0123456789';
const CHAR_UPPER_HEX = 'ABCDEF';
const CHAR_LOWER_HEX = 'abcdef';
const CHAR_BASE64 = '+/';
const CHAR_SYMBOLS = '!"#$%&\'()* +,-./:;<=>?@[\]^_`{|}~';
const CHAR_BRACKETS = '()[]{}<>';
const CHAR_PUNCT = ',.;:';
/**
* @return string
*/
public static function getRandomTotpBackupCode()
{
return self::getString(6, self::CHAR_DIGITS);
}
}

View File

@ -34,10 +34,8 @@ class d3backupcode extends BaseModel
*/
public function generateCode($sUserId)
{
$factory = new Factory();
$generator = $factory->getLowStrengthGenerator();
$sCode = d3RandomGenerator::getRandomTotpBackupCode();
$sCode = $generator->generateString(6, Generator::CHAR_DIGITS);
$this->assign(
[
'oxuserid' => $sUserId,