add methods to decrypt return data from router
[GitHub/Stricted/speedport-hybrid-php-api.git] / CryptLib / Random / Source / UniqID.php
CommitLineData
14d4f286
S
1<?php
2/**
3 * The UniqID Random Number Source
4 *
5 * This uses the internal `uniqid()` function to generate low strength random
6 * numbers.
7 *
8 * PHP version 5.3
9 *
10 * @category PHPCryptLib
11 * @package Random
12 * @subpackage Source
13 * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
14 * @copyright 2011 The Authors
15 * @license http://www.opensource.org/licenses/mit-license.html MIT License
16 * @version Build @@version@@
17 */
18
19namespace CryptLib\Random\Source;
20
21use CryptLib\Core\Strength;
22
23/**
24 * The UniqID Random Number Source
25 *
26 * This uses the internal `uniqid()` function to generate low strength random
27 * numbers.
28 *
29 * @category PHPCryptLib
30 * @package Random
31 * @subpackage Source
32 * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
33 * @codeCoverageIgnore
34 */
35class UniqID implements \CryptLib\Random\Source {
36
37 /**
38 * Return an instance of Strength indicating the strength of the source
39 *
40 * @return Strength An instance of one of the strength classes
41 */
42 public static function getStrength() {
43 return new Strength(Strength::LOW);
44 }
45
46 /**
47 * Generate a random string of the specified size
48 *
49 * @param int $size The size of the requested random string
50 *
51 * @return string A string of the requested size
52 */
53 public function generate($size) {
54 $result = '';
55 while (strlen($result) < $size) {
56 $result = uniqid($result, true);
57 }
58 return substr($result, 0, $size);
59 }
60
61}