当前位置: 首页>>代码示例>>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;未经允许,请勿转载。