XOOPS  2.6.0
Random.php
Go to the documentation of this file.
1 <?php
2 /*
3  * You may not change or alter any portion of this comment or credits
4  * of supporting developers from this source code or any supporting source code
5  * which is considered copyrighted (c) material of the original comment or credit authors.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  */
11 
12 namespace Xoops\Core;
13 
15 
28 class Random
29 {
41  public static function generateOneTimeToken($hash = 'sha512', $bytes = 64)
42  {
43  $factory = new Factory;
44  $generator = $factory->getLowStrengthGenerator();
45  $token = hash($hash, $generator->generate($bytes));
46  return $token;
47  }
48 
60  public static function generateKey($hash = 'sha512', $bytes = 128)
61  {
62  $factory = new Factory;
63  $generator = $factory->getMediumStrengthGenerator();
64  $token = hash($hash, $generator->generate($bytes));
65  return $token;
66  }
67 }
static generateOneTimeToken($hash= 'sha512', $bytes=64)
Definition: Random.php:41
static generateKey($hash= 'sha512', $bytes=128)
Definition: Random.php:60