コード例 #1
0
 public static function secureRandomString($length, $special_chars = true, $more_special_chars = true)
 {
     $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
     if ($special_chars) {
         $chars .= '!@#$%^&*()';
     }
     if ($more_special_chars) {
         $chars .= '-_ []{}<>~`+=,.;:/?|';
     }
     $password = '';
     for ($i = 0; $i < $length; $i++) {
         $password .= substr($chars, owa_coreAPI::random(0, strlen($chars) - 1), 1);
     }
     return $password;
 }