| Conditions | 4 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | public function generate($length) |
||
| 31 | { |
||
| 32 | $bytes = ''; |
||
| 33 | $length = (int)$length; |
||
| 34 | |||
| 35 | if (self::isAvailable() && $length > 0) { |
||
| 36 | $mcrypt = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); |
||
| 37 | if ($mcrypt !== false) { |
||
| 38 | $bytes = $mcrypt; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | return str_pad($bytes, $length, chr(0)); |
||
| 43 | } |
||
| 44 | |||
| 55 |