Skip to content
This repository
Browse code

FIX: check GetRandom() exists for RandomGenerator

  • Loading branch information...
commit a4ff1d3613483e852851f73b2a7fc71f0012ed8e 1 parent 23ed533
Sean Harvey authored July 01, 2012 wilr committed July 01, 2012

Showing 1 changed file with 6 additions and 5 deletions. Show diff stats Hide diff stats

  1. 11  security/RandomGenerator.php
11  security/RandomGenerator.php
@@ -47,8 +47,10 @@ function generateEntropy() {
47 47
 		if($isWin && class_exists('COM')) {
48 48
 			try {
49 49
 				$comObj = new COM('CAPICOM.Utilities.1');
50  
-				$e = base64_decode($comObj->GetRandom(64, 0));
51  
-				return $e;
  50
+
  51
+				if(is_callable(array($comObj,'GetRandom'))) {
  52
+					return  base64_decode($comObj->GetRandom(64, 0));
  53
+				}
52 54
 			} catch (Exception $ex) {
53 55
 			}
54 56
 		}
@@ -66,6 +68,5 @@ function generateEntropy() {
66 68
 	 */
67 69
 	function generateHash($algorithm = 'whirlpool') {
68 70
 		return hash($algorithm, $this->generateEntropy());
69  
-	}
70  
-	
71  
-}
  71
+	}	
  72
+}

0 notes on commit a4ff1d3

Please sign in to comment.
Something went wrong with that request. Please try again.