FIX: check GetRandom() exists for RandomGenerator

See http://open.silverstripe.org/ticket/6416
This commit is contained in:
Sean Harvey 2012-07-01 21:04:50 +12:00 committed by Will Rossiter
parent 23ed5335e6
commit a4ff1d3613

View File

@ -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());
}
}
}
}