summaryrefslogtreecommitdiff
path: root/inc/PassHash.class.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-08-04 09:44:57 +0200
committerAndreas Gohr <andi@splitbrain.org>2013-08-04 09:44:57 +0200
commit08d5d52a34fa7f972f3a7da214f796ad72a9d944 (patch)
tree70b178a661548918bb3dcb68dff1b9c2d1ea18c8 /inc/PassHash.class.php
parent99dca51357b98d8450d43d66b5596504722809c0 (diff)
downloadrpg-08d5d52a34fa7f972f3a7da214f796ad72a9d944.tar.gz
rpg-08d5d52a34fa7f972f3a7da214f796ad72a9d944.tar.bz2
FS#2829 check if auth_random is available in PassHash
Diffstat (limited to 'inc/PassHash.class.php')
-rw-r--r--inc/PassHash.class.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/inc/PassHash.class.php b/inc/PassHash.class.php
index 607661a22..db6a3a77c 100644
--- a/inc/PassHash.class.php
+++ b/inc/PassHash.class.php
@@ -98,7 +98,7 @@ class PassHash {
$salt = '';
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
for($i = 0; $i < $len; $i++) {
- $salt .= $chars[auth_random(0, 61)];
+ $salt .= $chars[$this->random(0, 61)];
}
return $salt;
}
@@ -541,4 +541,20 @@ class PassHash {
return ($raw_output) ? pack($pack, $output) : $output;
}
+
+ /**
+ * Use DokuWiki's secure random generator if available
+ *
+ * @param $min
+ * @param $max
+ *
+ * @return int
+ */
+ protected function random($min, $max){
+ if(function_exists('auth_random')){
+ return auth_random($min, $max);
+ }else{
+ return mt_rand($min, $max);
+ }
+ }
}