MediaWiki REL1_32
CryptRand.php
Go to the documentation of this file.
1<?php
30class CryptRand {
34 const MIN_ITERATIONS = 1000;
35
39 const MSEC_PER_BYTE = 0.5;
40
48 protected function initialRandomState() {
49 return '';
50 }
51
61 protected function driftHash( $data ) {
62 return '';
63 }
64
72 protected function randomState() {
73 return '';
74 }
75
85 public function wasStrong() {
86 return true;
87 }
88
98 public function generate( $bytes ) {
99 $bytes = floor( $bytes );
100 return random_bytes( $bytes );
101 }
102
110 public function generateHex( $chars ) {
111 return MWCryptRand::generateHex( $chars );
112 }
113}
generate( $bytes)
Generate a run of cryptographically random data and return it in raw binary form.
Definition CryptRand.php:98
wasStrong()
Return a boolean indicating whether or not the source used for cryptographic random bytes generation ...
Definition CryptRand.php:85
driftHash( $data)
Randomly hash data while mixing in clock drift data for randomness.
Definition CryptRand.php:61
randomState()
Return a rolling random state initially build using data from unstable sources.
Definition CryptRand.php:72
generateHex( $chars)
Generate a run of cryptographically random data and return it in hexadecimal string format.
const MSEC_PER_BYTE
Definition CryptRand.php:39
initialRandomState()
Initialize an initial random state based off of whatever we can find.
Definition CryptRand.php:48
const MIN_ITERATIONS
Definition CryptRand.php:34
static generateHex( $chars)
Generate a run of cryptographically random data and return it in hexadecimal string format.