rand() public méthode

Will attempt to read from a systems RNG if it exists or else utilises a simple random character to maximum length process. Simplicity is a factor better left for development...
public rand ( string | integer $minimum, string | integer $maximum ) : string
$minimum string | integer
$maximum string | integer
Résultat string
 public function testRand()
 {
     $math = new Zend_Crypt_Math();
     $higher = '155172898181473697471232257763715539915724801966915404479707795314057629378541917580651227423698188993727816152646631438561595825688188889951272158842675419950341258706556549803580104870537681476726513255747040765857479291291572334510643245094715007229621094194349783925984760375594985848253359305585439638443';
     $lower = '155172898181473697471232257763715539915724801966915404479707795314057629378541917580651227423698188993727816152646631438561595825688188889951272158842675419950341258706556549803580104870537681476726513255747040765857479291291572334510643245094715007229621094194349783925984760375594985848253359305585439638442';
     $result = $math->rand($lower, $higher);
     $this->assertTrue(bccomp($result, $higher) !== '1');
     $this->assertTrue(bccomp($result, $lower) !== '-1');
 }
Exemple #2
0
 public function testRand()
 {
     try {
         $math = new Zend_Crypt_Math_BigInteger();
     } catch (Zend_Crypt_Math_BigInteger_Exception $e) {
         if (strpos($e->getMessage(), 'big integer precision math support not detected') !== false) {
             $this->markTestSkipped($e->getMessage());
         } else {
             throw $e;
         }
     }
     $math = new Zend_Crypt_Math();
     $higher = '155172898181473697471232257763715539915724801966915404479707795314057629378541917580651227423698188993727816152646631438561595825688188889951272158842675419950341258706556549803580104870537681476726513255747040765857479291291572334510643245094715007229621094194349783925984760375594985848253359305585439638443';
     $lower = '155172898181473697471232257763715539915724801966915404479707795314057629378541917580651227423698188993727816152646631438561595825688188889951272158842675419950341258706556549803580104870537681476726513255747040765857479291291572334510643245094715007229621094194349783925984760375594985848253359305585439638442';
     $result = $math->rand($lower, $higher);
     $this->assertTrue(bccomp($result, $higher) !== '1');
     $this->assertTrue(bccomp($result, $lower) !== '-1');
 }