From a4ff1d3613483e852851f73b2a7fc71f0012ed8e Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Sun, 1 Jul 2012 21:04:50 +1200 Subject: [PATCH] FIX: check GetRandom() exists for RandomGenerator See http://open.silverstripe.org/ticket/6416 --- security/RandomGenerator.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/security/RandomGenerator.php b/security/RandomGenerator.php index 4d03bbf3c..f8f926d4c 100644 --- a/security/RandomGenerator.php +++ b/security/RandomGenerator.php @@ -47,8 +47,10 @@ class RandomGenerator { if($isWin && class_exists('COM')) { try { $comObj = new COM('CAPICOM.Utilities.1'); - $e = base64_decode($comObj->GetRandom(64, 0)); - return $e; + + if(is_callable(array($comObj,'GetRandom'))) { + return base64_decode($comObj->GetRandom(64, 0)); + } } catch (Exception $ex) { } } @@ -66,6 +68,5 @@ class RandomGenerator { */ function generateHash($algorithm = 'whirlpool') { return hash($algorithm, $this->generateEntropy()); - } - -} + } +} \ No newline at end of file