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


PHP Encryption\Encrypter類代碼示例

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


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

示例1: readCallback

 public static function readCallback($payload)
 {
     $crypt = new Encrypter(base64_decode(Config::get('services.etupay.key')), 'AES-256-CBC');
     $payload = json_decode($crypt->decrypt($payload));
     if ($payload && is_numeric($payload->service_data)) {
         $paymentId = $payload->service_data;
         $payment = Payment::findOrFail($paymentId);
         switch ($payload->step) {
             case 'INITIALISED':
                 $payment->state = 'returned';
                 break;
             case 'PAID':
             case 'AUTHORISATION':
                 $payment->state = 'paid';
                 break;
             case 'REFUSED':
             case 'CANCELED':
                 $payment->state = 'refused';
                 break;
             case 'REFUNDED':
                 $payment->state = 'refunded';
                 break;
         }
         $payment->informations = ['transaction_id' => $payload->transaction_id];
         $payment->save();
         if ($payment->newcomer) {
             $payment->newcomer->updateWei();
         } elseif ($payment->student) {
             $payment->student->updateWei();
         }
         return $payment;
     }
     return null;
 }
開發者ID:ungdev,項目名稱:integration-UTT,代碼行數:34,代碼來源:EtuPay.php

示例2: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('encrypter', function ($app) {
         $encrypter = new Encrypter($app['config']['app.key']);
         if ($app['config']->has('app.cipher')) {
             $encrypter->setCipher($app['config']['app.cipher']);
         }
         return $encrypter;
     });
 }
開發者ID:visualturk,項目名稱:framework,代碼行數:15,代碼來源:EncryptionServiceProvider.php

示例3: decrypt

 /**
  * Descriptografa os dados.
  *
  * @param  array $data
  * @return array
  */
 public function decrypt(array $data)
 {
     if (!isset($data['secret'])) {
         return $data;
     }
     $key = md5($data['secret'] . '-' . Config::get('app.key'));
     $cipher = Config::get('app.cipher');
     $encrypter = new Encrypter($key, $cipher);
     foreach ($data as $key => $value) {
         if (!empty($value) and in_array($key, $this->getEncryptable())) {
             $data[$key] = $encrypter->decrypt($value);
         }
     }
     return $data;
 }
開發者ID:resultsystems,項目名稱:protectall,代碼行數:21,代碼來源:BaseCryptRepository.php

示例4: getEncrypterForKeyAndCipher

 /**
  * Get the proper encrypter instance for the given key and cipher.
  *
  * @param  string  $key
  * @param  string  $cipher
  * @return mixed
  *
  * @throws \RuntimeException
  */
 protected function getEncrypterForKeyAndCipher($key, $cipher)
 {
     if (Encrypter::supported($key, $cipher)) {
         return new Encrypter($key, $cipher);
     } elseif (McryptEncrypter::supported($key, $cipher)) {
         return new McryptEncrypter($key, $cipher);
     } else {
         throw new RuntimeException('No supported encrypter found. The cipher and / or key length are invalid.');
     }
 }
開發者ID:Penderis,項目名稱:penderis.co.za,代碼行數:19,代碼來源:EncryptionServiceProvider.php

示例5: handle

 /**
  * executes the command
  */
 protected function handle()
 {
     $config = $this->getApplication()->config();
     if (!$config->has('url') || !$this->confirm('Is your donePM API url ' . $config->get('url') . '?', true)) {
         $url = $this->ask('What is your donePM API url?', Application::API_URL);
         $config->set('url', $url);
     }
     if (!$config->has('email') || !$this->confirm('Is your donePM email ' . $config->get('email') . '?', true)) {
         $email = $this->ask('What is your donePM email?');
         $config->set('email', $email);
     }
     if (!$config->has('password') || !$this->confirm('Do you want to keep your password?', true)) {
         $password = $this->secret('What is your donePM password? (will be stored encrypted)');
         $key = $config->get('key', Str::random(16));
         $encrypter = new Encrypter($key);
         $config->set('password', $encrypter->encrypt($password));
         $config->set('key', $key);
     }
     $this->getApplication()->writeConfig($config);
     return 0;
 }
開發者ID:donepm,項目名稱:cli-client,代碼行數:24,代碼來源:InitCommand.php

示例6: getEncrypter

 private static function getEncrypter()
 {
     $config = static::getEncrypterVariables();
     $key = $config['key'];
     $cipher = $config['cipher'];
     if (Encrypter::supported($key, $cipher)) {
         return new Encrypter($key, $cipher);
     } elseif (McryptEncrypter::supported($key, $cipher)) {
         return new McryptEncrypter($key, $cipher);
     } else {
         throw new RuntimeException('No supported encrypter found. The cipher and / or key length are invalid.');
     }
 }
開發者ID:DraperStudio,項目名稱:Laravel-Database,代碼行數:13,代碼來源:EncryptAttributes.php

示例7: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('encrypter', function ($app) {
         $config = $app->make('config')->get('app');
         $key = $config['key'];
         $cipher = $config['cipher'];
         if (Encrypter::supported($key, $cipher)) {
             return new Encrypter($key, $cipher);
         } elseif (McryptEncrypter::supported($key, $cipher)) {
             return new McryptEncrypter($key, $cipher);
         } else {
             throw new RuntimeException('No supported encrypter found. The cipher and / or key length are invalid.');
         }
     });
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:20,代碼來源:EncryptionServiceProvider.php

示例8: decrypted

 /**
  * Decrypt the value.
  *
  * @return string
  */
 public function decrypted()
 {
     if (!($value = $this->object->getValue())) {
         return null;
     }
     return $this->encrypter->decrypt($value);
 }
開發者ID:AkibaTech,項目名稱:encrypted-field_type,代碼行數:12,代碼來源:EncryptedFieldTypePresenter.php

示例9: restore

 /**
  * Restore the value.
  *
  * @param $value
  * @return string
  */
 public function restore($value)
 {
     if (array_get($this->fieldType->getConfig(), 'auto_decrypt') === true) {
         return $this->encrypter->decrypt($value);
     }
     return $value;
 }
開發者ID:visualturk,項目名稱:encrypted-field_type,代碼行數:13,代碼來源:EncryptedFieldTypeModifier.php

示例10: encrypt

 /**
  * Encrypt the cookies on an outgoing response.
  *
  * @param  \Symfony\Component\HttpFoundation\Response  $response
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function encrypt(Response $response)
 {
     foreach ($response->headers->getCookies() as $key => $c) {
         $encrypted = $this->encrypter->encrypt($c->getValue());
         $response->headers->setCookie($this->duplicate($c, $encrypted));
     }
     return $response;
 }
開發者ID:yashb,項目名稱:generator,代碼行數:14,代碼來源:Guard.php

示例11: decrypted

 /**
  * Decrypt the value.
  *
  * @return string
  */
 public function decrypted()
 {
     if (!($value = $this->object->getValue())) {
         return null;
     }
     // Return the value if it's already decoded.
     if (array_get($this->object->getConfig(), 'auto_decrypt') === true) {
         return $value;
     }
     return $this->encrypter->decrypt($value);
 }
開發者ID:visualturk,項目名稱:encrypted-field_type,代碼行數:16,代碼來源:EncryptedFieldTypePresenter.php

示例12: put

 /**
  * Store an item in the cache for a given number of minutes.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @param  int     $minutes
  * @return void
  */
 public function put($key, $value, $minutes)
 {
     // All of the cached values in the database are encrypted in case this is used
     // as a session data store by the consumer. We'll also calculate the expire
     // time and place that on the table so we will check it on our retrieval.
     $value = $this->encrypter->encrypt($value);
     $timestamp = $this->getTime();
     $expiration = $ttl = $timestamp + $minutes * 60;
     // Remove key/value store if exists
     $this->forget($key);
     $this->columnFamily->insert($this->prefix . $key, compact('value', 'expiration'), $timestamp, $ttl);
 }
開發者ID:aaronbullard,項目名稱:cassandra-cache,代碼行數:20,代碼來源:CassandraStore.php

示例13: deserializeToken

 /**
  * Deserializes token.
  *
  * @param string $payload
  * @return AuthToken|null
  */
 public function deserializeToken($payload)
 {
     try {
         $data = $this->encrypter->decrypt($payload);
     } catch (DecryptException $e) {
         return null;
     }
     if (empty($data['id']) || empty($data['key'])) {
         return null;
     }
     $token = $this->generateAuthToken($data['key']);
     $token->setAuthIdentifier($data['id']);
     return $token;
 }
開發者ID:bytesflipper,項目名稱:laravel-auth-token,代碼行數:20,代碼來源:AbstractAuthTokenProvider.php

示例14: put

 /**
  * Store an item in the cache for a given number of minutes.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @param  int     $minutes
  * @return void
  */
 public function put($key, $value, $minutes)
 {
     $key = $this->prefix . $key;
     // All of the cached values in the database are encrypted in case this is used
     // as a session data store by the consumer. We'll also calculate the expire
     // time and place that on the table so we will check it on our retrieval.
     $value = $this->encrypter->encrypt($value);
     $expiration = $this->getTime() + $minutes * 60;
     try {
         $this->table()->insert(compact('key', 'value', 'expiration'));
     } catch (\Exception $e) {
         $this->table()->where('key', '=', $key)->update(compact('value', 'expiration'));
     }
 }
開發者ID:Thomvh,項目名稱:turbine,代碼行數:22,代碼來源:DatabaseStore.php

示例15: deserializeToken

 /**
  * Deserializes token.
  *
  * @param string $payload
  * @return AuthToken|null
  */
 public function deserializeToken($payload)
 {
     try {
         $payload = str_replace(array('-', '_'), array('+', '/'), $payload);
         $data = $this->encrypter->decrypt($payload);
     } catch (DecryptException $e) {
         return null;
     }
     if (empty($data['id']) || empty($data['key']) || empty($data['userAgent'])) {
         return null;
     }
     $token = $this->generateAuthToken($data['key']);
     $token->setAuthIdentifier($data['id']);
     $token->setUserAgent($data['userAgent']);
     return $token;
 }
開發者ID:tfleet,項目名稱:tf-auth-token,代碼行數:22,代碼來源:AbstractAuthTokenProvider.php


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