當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Encrypter::decrypt方法代碼示例

本文整理匯總了PHP中Illuminate\Contracts\Encryption\Encrypter::decrypt方法的典型用法代碼示例。如果您正苦於以下問題:PHP Encrypter::decrypt方法的具體用法?PHP Encrypter::decrypt怎麽用?PHP Encrypter::decrypt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Contracts\Encryption\Encrypter的用法示例。


在下文中一共展示了Encrypter::decrypt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: tokensMatch

 /**
  * Determine if the session and input CSRF tokens match.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return bool
  */
 protected function tokensMatch($request)
 {
     $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
     if (!$token && ($header = $request->header('X-XSRF-TOKEN'))) {
         $token = $this->encrypter->decrypt($header);
     }
     return Str::equals($request->session()->token(), $token);
 }
開發者ID:alvarobfdev,項目名稱:LaravelCore,代碼行數:14,代碼來源:VerifyCsrfToken.php

示例2: decryptArray

 /**
  * Decrypt an array based cookie.
  *
  * @param  array  $cookie
  * @return array
  */
 protected function decryptArray(array $cookie)
 {
     $decrypted = array();
     foreach ($cookie as $key => $value) {
         $decrypted[$key] = $this->encrypter->decrypt($value);
     }
     return $decrypted;
 }
開發者ID:GeorgeShazkho,項目名稱:micros-de-conce,代碼行數:14,代碼來源:EncryptCookies.php

示例3: prepareForUnserialize

 /**
  * Prepare the raw string data from the session for unserialization.
  *
  * @param  string  $data
  * @return string
  */
 protected function prepareForUnserialize($data)
 {
     try {
         return $this->encrypter->decrypt($data);
     } catch (DecryptException $e) {
         return json_encode([]);
     }
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:14,代碼來源:EncryptedStore.php

示例4: onReady

 /**
  * Fired just before building.
  *
  * @param Encrypter $encrypter
  * @param Request   $request
  */
 public function onReady(Encrypter $encrypter, Request $request)
 {
     if ($code = $request->get('code')) {
         array_set($this->parameters, 'code', $encrypter->decrypt($code));
     }
     if ($email = $request->get('email')) {
         array_set($this->parameters, 'email', $encrypter->decrypt($email));
     }
 }
開發者ID:jacksun101,項目名稱:users-module,代碼行數:15,代碼來源:ResetPasswordFormCriteria.php

示例5: tokensMatch

 /**
  * Determine if the session and input CSRF tokens match.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return bool
  */
 protected function tokensMatch($request)
 {
     // Get tokens from session and the request
     $sessionToken = $request->session()->token();
     $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
     if (!$token && ($header = $request->header('X-XSRF-TOKEN'))) {
         $token = $this->encrypter->decrypt($header);
     }
     if (!is_string($sessionToken) || !is_string($token)) {
         return false;
     }
     // Validate them
     return hash_equals((string) $request->session()->token(), (string) $token);
 }
開發者ID:influendo,項目名稱:laravel-survivor,代碼行數:20,代碼來源:SurvivorController.php

示例6: handle

 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @param UserActivator           $activator
  * @param Encrypter               $encrypter
  * @param Request                 $request
  * @return bool
  */
 public function handle(UserRepositoryInterface $users, UserActivator $activator, Encrypter $encrypter, Request $request)
 {
     $code = $request->get('code');
     $email = $request->get('email');
     if (!$code || !$email) {
         return false;
     }
     $code = $encrypter->decrypt($code);
     $email = $encrypter->decrypt($email);
     if (!($user = $users->findByEmail($email))) {
         return false;
     }
     return $activator->activate($user, $code);
 }
開發者ID:jacksun101,項目名稱:users-module,代碼行數:23,代碼來源:HandleActivateRequest.php

示例7: date

 function it_fails_with_string(Encrypter $encrypter, Request $request)
 {
     $time = date("Y-m-d H:i:s", strtotime("30 seconds ago"));
     $request->get('_guard_opened')->willReturn($time);
     $encrypter->decrypt($time)->willReturn($time);
     $this->validate($request)->shouldReturn(false);
 }
開發者ID:ryanwinchester,項目名稱:laravel-spamguard,代碼行數:7,代碼來源:SpamTimerValidatorSpec.php

示例8: validate

 /**
  * Validate the request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  array $params
  * @return bool
  */
 public function validate($request, $params = [])
 {
     $this->params = $params;
     try {
         $timeOpened = $this->encrypter->decrypt($request->get('_guard_opened'));
     } catch (DecryptException $e) {
         return false;
     }
     if (!is_numeric($timeOpened)) {
         return false;
     }
     $timeElapsed = time() - $timeOpened;
     $tooFast = $timeElapsed < $this->getMinTime();
     $tooSlow = $timeElapsed > $this->getMaxTime();
     return !$tooFast && !$tooSlow;
 }
開發者ID:ryanwinchester,項目名稱:laravel-spamguard,代碼行數:23,代碼來源:SpamTimerValidator.php

示例9: decryptPayload

 /**
  * Attempt to decrypt payload.
  */
 protected function decryptPayload()
 {
     try {
         $decrypted = $this->encrypter->decrypt($this->encryptedValue);
         $this->decryptedValue = json_decode($decrypted);
     } catch (\Exception $e) {
         throw new Exceptions\InvalidEncryptionFormat($e->getMessage());
     }
 }
開發者ID:classid,項目名稱:core-payload,代碼行數:12,代碼來源:Broker.php

示例10: get

 /**
  * Retrieve an item from the cache by key.
  *
  * @param  string  $key
  * @return mixed
  */
 public function get($key)
 {
     $prefixed = $this->prefix . $key;
     $cache = $this->table()->where('key', '=', $prefixed)->first();
     // If we have a cache record we will check the expiration time against current
     // time on the system and see if the record has expired. If it has, we will
     // remove the records from the database table so it isn't returned again.
     if (!is_null($cache)) {
         if (is_array($cache)) {
             $cache = (object) $cache;
         }
         if (time() >= $cache->expiration) {
             $this->forget($key);
             return;
         }
         return $this->encrypter->decrypt($cache->value);
     }
 }
開發者ID:betes-curieuses-design,項目名稱:ElieJosiePhotographie,代碼行數:24,代碼來源:DatabaseStore.php

示例11: decryptArray

 /**
  * Decrypt an array based cookie.
  *
  * @param  array  $cookie
  * @return array
  */
 protected function decryptArray(array $cookie)
 {
     $decrypted = [];
     foreach ($cookie as $key => $value) {
         if (is_string($value)) {
             $decrypted[$key] = $this->encrypter->decrypt($value);
         }
     }
     return $decrypted;
 }
開發者ID:focuslife,項目名稱:v0.1,代碼行數:16,代碼來源:EncryptCookies.php

示例12: incrementOrDecrement

 /**
  * Increment or decrement an item in the cache.
  *
  * @param  string  $key
  * @param  mixed  $value
  * @param  \Closure  $callback
  * @return void
  */
 protected function incrementOrDecrement($key, $value, Closure $callback)
 {
     $prefixed = $this->prefix . $key;
     $cache = $this->table()->where('key', $prefixed)->lockForUpdate()->first();
     if (!is_null($cache)) {
         $current = $this->encrypter->decrypt($cache->value);
         if (is_numeric($current)) {
             $this->table()->where('key', $prefixed)->update(['value' => $this->encrypter->encrypt($callback($current))]);
         }
     }
 }
開發者ID:manhvu1212,項目名稱:videoplatform,代碼行數:19,代碼來源:DatabaseStore.php

示例13: tokensMatch

 /**
  * @param \Illuminate\Http\Request $request
  *
  * @return bool
  */
 protected function tokensMatch($request)
 {
     $sessionToken = $request->session()->token();
     $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
     if (!$token && ($header = $request->header('X-XSRF-TOKEN'))) {
         $token = $this->encrypter->decrypt($header);
     }
     if (!is_string($sessionToken) || !is_string($token)) {
         return false;
     }
     return hash_equals($sessionToken, $token);
 }
開發者ID:notadd,項目名稱:framework,代碼行數:17,代碼來源:VerifyCsrfToken.php

示例14: getActivate

 /**
  * Activate a user by token
  * @param  string  $token
  * @param  Request $request
  * @param  Events  $events
  * @return Illuminate\Http\Response
  */
 public function getActivate(Encrypter $encrypter, Request $request, Events $events, $token)
 {
     try {
         $data = json_decode($encrypter->decrypt($token));
         if (is_object($data) && isset($data->id) && is_numeric($data->id) && isset($data->expires) && with(new Carbon(date('Y-m-d H:i:s', $data->expires)))->gt(Carbon::now())) {
             $user = $this->activateUser($data->id);
             $events->fire(new UserActivated($user));
             return $this->userWasActivated($data->id);
         } else {
             throw new Exception("Invalid token");
         }
     } catch (Exception $e) {
         return $this->userWasNotActivated();
     }
 }
開發者ID:ruysu,項目名稱:laravel-core,代碼行數:22,代碼來源:ActivatesUsers.php

示例15: incrementOrDecrement

 /**
  * Increment or decrement an item in the cache.
  *
  * @param string $key        	
  * @param mixed $value        	
  * @param \Closure $callback        	
  * @return int|bool
  */
 protected function incrementOrDecrement($key, $value, Closure $callback)
 {
     return $this->connection->transaction(function () use($key, $value, $callback) {
         $prefixed = $this->prefix . $key;
         $cache = $this->table()->where('key', $prefixed)->lockForUpdate()->first();
         if (is_null($cache)) {
             return false;
         }
         $current = $this->encrypter->decrypt($cache->value);
         $new = $callback($current, $value);
         if (!is_numeric($current)) {
             return false;
         }
         $this->table()->where('key', $prefixed)->update(['value' => $this->encrypter->encrypt($new)]);
         return $new;
     });
 }
開發者ID:sapwoo,項目名稱:portfolio,代碼行數:25,代碼來源:DatabaseStore.php


注:本文中的Illuminate\Contracts\Encryption\Encrypter::decrypt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。