diff --git a/inc/PassHash.class.php b/inc/PassHash.class.php
index 607661a2205c0b00e58a18806850fbf2473aeb85..db6a3a77cc231e88017a136726214ffb5a5cf4f3 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);
+        }
+    }
 }