• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Crypt/Math.php

00001 <?php
00026 require_once 'Zend/Crypt/Math/BigInteger.php';
00027 
00034 class Zend_Crypt_Math extends Zend_Crypt_Math_BigInteger
00035 {
00036 
00047     public function rand($minimum, $maximum)
00048     {
00049         if (file_exists('/dev/urandom')) {
00050             $frandom = fopen('/dev/urandom', 'r');
00051             if ($frandom !== false) {
00052                 return fread($frandom, strlen($maximum) - 1);
00053             }
00054         }
00055         if (strlen($maximum) < 4) {
00056             return mt_rand($minimum, $maximum - 1);
00057         }
00058         $rand = '';
00059         $i2 = strlen($maximum) - 1;
00060         for ($i = 1;$i < $i2;$i++) {
00061             $rand .= mt_rand(0,9);
00062         }
00063         $rand .= mt_rand(0,9);
00064         return $rand;
00065     }
00066 
00074     public function btwoc($long) {
00075         if (ord($long[0]) > 127) {
00076             return "\x00" . $long;
00077         }
00078         return $long;
00079     }
00080 
00087     public function fromBinary($binary) {
00088         return $this->_math->binaryToInteger($binary);
00089     }
00090 
00097     public function toBinary($integer)
00098     {
00099         return $this->_math->integerToBinary($integer);
00100     }
00101 
00102 }

Generated on Thu Apr 19 2012 17:01:16 for openbiz by  doxygen 1.7.2