当前位置: 首页>>代码示例>>PHP>>正文


PHP Str::random方法代码示例

本文整理汇总了PHP中Laravel\Str::random方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::random方法的具体用法?PHP Str::random怎么用?PHP Str::random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Laravel\Str的用法示例。


在下文中一共展示了Str::random方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: id

 /**
  * Get a new session ID that isn't assigned to any current session.
  *
  * @return string
  */
 public function id()
 {
     $session = array();
     // We'll containue generating random IDs until we find an ID that is
     // not currently assigned to a session. This is almost definitely
     // going to happen on the first iteration.
     do {
         $session = $this->load($id = Str::random(40));
     } while (!is_null($session));
     return $id;
 }
开发者ID:victoroliveira1605,项目名称:Laravel-Bootstrap,代码行数:16,代码来源:driver.php

示例2: set_app_key

 public static function set_app_key($arguments = array())
 {
     $key = Str::random(array_get($arguments, 0, 32));
     // Set application config file key
     $config_path = path('app') . 'config' . DS . 'application' . EXT;
     $config = File::get($config_path);
     $newConfig = str_replace("'key' => '',", "'key' => '{$key}',", $config, $count);
     if (isset($newConfig) and $newConfig != '') {
         if ($count > 0) {
             File::put($config_path, $newConfig);
             Log::info('App configuration updated with secure key');
         }
     } else {
         Log::error('App configuration secure was not updated with secure key. A key already exists.');
     }
 }
开发者ID:juaniiie,项目名称:mwi,代码行数:16,代码来源:installer.php

示例3: id

 /**
  * Get a new session ID that isn't assigned to any current session.
  *
  * @return string
  */
 public function id()
 {
     $session = array();
     // If the driver is an instance of the Cookie driver, we are able to
     // just return any string since the Cookie driver has no real idea
     // of a server side persisted session with an ID.
     if ($this instanceof Cookie) {
         return Str::random(40);
     }
     // We'll continue generating random IDs until we find an ID that is
     // not currently assigned to a session. This is almost definitely
     // going to happen on the first iteration.
     do {
         $session = $this->load($id = Str::random(40));
     } while (!is_null($session));
     return $id;
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:22,代码来源:driver.php

示例4: generate

 /**
  * Generate a random key for the application.
  *
  * @param  array  $arguments
  * @return void
  */
 public function generate($arguments = array())
 {
     // By default the Crypter class uses AES-256 encryption which uses
     // a 32 byte input vector, so that is the length of string we will
     // generate for the application token unless another length is
     // specified through the CLI.
     $key = Str::random(array_get($arguments, 0, 32));
     $config = File::get($this->path);
     $config = str_replace("'key' => '',", "'key' => '{$key}',", $config, $count);
     File::put($this->path, $config);
     if ($count > 0) {
         echo "Configuration updated with secure key!";
     } else {
         echo "An application key already exists!";
     }
     echo PHP_EOL;
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:23,代码来源:key.php

示例5: load

 /**
  * Load the session for the current request.
  *
  * @param  string  $id
  * @return void
  */
 public function load($id)
 {
     if (!is_null($id)) {
         $this->session = $this->driver->load($id);
     }
     // If the session doesn't exist or is invalid we will create a new session
     // array and mark the session as being non-existent. Some drivers, such as
     // the database driver, need to know whether it exists.
     if (is_null($this->session) or static::expired($this->session)) {
         $this->exists = false;
         $this->session = $this->driver->fresh();
     }
     // A CSRF token is stored in every session. The token is used by the Form
     // class and the "csrf" filter to protect the application from cross-site
     // request forgery attacks. The token is simply a random string.
     if (!$this->has(Session::csrf_token)) {
         $this->put(Session::csrf_token, Str::random(40));
     }
 }
开发者ID:perryhau,项目名称:Laravel-1,代码行数:25,代码来源:payload.php

示例6: testUserCanBeRecalledViaCookie

 /**
  * Test the Auth::recall method.
  *
  * @group laravel
  */
 public function testUserCanBeRecalledViaCookie()
 {
     Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
     $cookie = Crypter::encrypt('1|' . Str::random(40));
     Cookie::forever('authloginstub_remember', $cookie);
     $auth = new AuthLoginStub();
     $this->assertEquals('Taylor Otwell', $auth->user()->name);
     $this->assertTrue($auth->user()->id === $_SERVER['auth.login.stub']['user']);
 }
开发者ID:raykwok,项目名称:laravel,代码行数:14,代码来源:auth.test.php

示例7: remember

 /**
  * Store a user's token in a long-lived cookie.
  *
  * @param  string  $token
  * @return void
  */
 protected function remember($token)
 {
     $token = Crypter::encrypt($token . '|' . Str::random(40));
     $this->cookie($this->recaller(), $token, Cookie::forever);
 }
开发者ID:albertpaulp,项目名称:PrettyBoot,代码行数:11,代码来源:driver.php

示例8: regenerate

 /**
  * Assign a new, random ID to the session.
  *
  * @return void
  */
 public function regenerate()
 {
     $this->session['id'] = Str::random(40);
     $this->exists = false;
 }
开发者ID:bamper,项目名称:laravel.com,代码行数:10,代码来源:payload.php

示例9: make

 public static function make($value, $rounds = 8)
 {
     $work = str_pad($rounds, 2, '0', STR_PAD_LEFT);
     if (function_exists('openssl_random_pseudo_bytes')) {
         $salt = openssl_random_pseudo_bytes(16);
     } else {
         $salt = Str::random(40);
     }
     $salt = substr(strtr(base64_encode($salt), '+', '.'), 0, 22);
     return crypt($value, '$2a$' . $work . '$' . $salt);
 }
开发者ID:laravelbook,项目名称:framework3,代码行数:11,代码来源:laravel_lite.php


注:本文中的Laravel\Str::random方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。