• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Encryption\Encrypter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Illuminate\Encryption\Encrypter的典型用法代码示例。如果您正苦于以下问题:PHP Encrypter类的具体用法?PHP Encrypter怎么用?PHP Encrypter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Encrypter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: retrieve

 /**
  * @param $secret
  * @return string
  */
 public function retrieve($secret)
 {
     if (!($idKeyArray = explode(';', $secret)) || count($idKeyArray) != 2) {
         throw new \InvalidArgumentException('Invalid secret');
     }
     list($id, $key) = $idKeyArray;
     $id = preg_replace("/[^a-zA-Z\\d]/", '', $id);
     if (!($password = $this->storage->get($id))) {
         throw new PhPsstException('No password with that ID found', PhPsstException::NO_PASSWORD_WITH_ID_FOUND);
     }
     $encrypter = new Encrypter($key, $this->cipher);
     $password->decreaseViews();
     if ($password->getViews() > 0) {
         $this->storage->store($password, true);
     } else {
         $this->storage->delete($password);
     }
     return $encrypter->decrypt($password->getPassword());
 }
开发者ID:felixsand,项目名称:phpsst,代码行数:23,代码来源:PhPsst.php


示例9: decrypt

 /**
  * Decrypt the given value.
  *
  * @param string $payload
  * @return string 
  * @throws \Illuminate\Contracts\Encryption\DecryptException
  * @static 
  */
 public static function decrypt($payload)
 {
     return \Illuminate\Encryption\Encrypter::decrypt($payload);
 }
开发者ID:satriashp,项目名称:tour,代码行数:12,代码来源:_ide_helper.php


示例10: setMode

 /**
  * Set the encryption mode.
  *
  * @param string $mode
  * @return void 
  * @static 
  */
 public static function setMode($mode)
 {
     \Illuminate\Encryption\Encrypter::setMode($mode);
 }
开发者ID:nmkr,项目名称:basic-starter,代码行数:11,代码来源:_ide_helper.php


示例11: function

<?php

use Illuminate\Encryption\Encrypter;
require_once 'vendor/autoload.php';
/**
 * Illuminate/encryption
 *
 * Requires: symfony/security-core
 *
 * @source https://github.com/illuminate/encryption
 */
$app = new \Slim\Slim();
$app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware());
/*
 * This key is used by the Illuminate encrypter service and should be set
 * to a random, 16-character string, otherwise these encrypted strings
 * will not be safe. Please do this before deploying an application!
 */
$key = '1hs8heis)2(-*3d.';
$app->get('/', function () use($key) {
    $encrypter = new Encrypter($key);
    // Encrypt Hello World string
    $encryptedHelloWorld = $encrypter->encrypt('Hello World');
    echo "Here is the encrypted string: <hr>" . $encryptedHelloWorld . "<br><br><br>";
    // Decrypt encrypted string
    $decryptedHelloWorld = $encrypter->decrypt($encryptedHelloWorld);
    echo "Here is the decrypted string: <hr>" . $decryptedHelloWorld . "<br><br>";
});
$app->run();
开发者ID:aaemnnosttv,项目名称:Torch,代码行数:29,代码来源:index.php


示例12: setupEncryptionKey

 protected function setupEncryptionKey($force = false)
 {
     $validKey = false;
     $cipher = Config::get('app.cipher');
     $keyLength = $this->getKeyLength($cipher);
     $randomKey = $this->getRandomKey($cipher);
     if ($force) {
         $key = $randomKey;
     } else {
         $this->line(sprintf('Enter a new value of %s characters, or press ENTER to use the generated key', $keyLength));
         while (!$validKey) {
             $key = $this->ask('Application key', $randomKey);
             $validKey = Encrypter::supported($key, $cipher);
             if (!$validKey) {
                 $this->error(sprintf('[ERROR] Invalid key length for "%s" cipher. Supplied key must be %s characters in length.', $cipher, $keyLength));
             }
         }
     }
     $this->writeToConfig('app', ['key' => $key]);
     $this->info(sprintf('Application key [%s] set successfully.', $key));
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:21,代码来源:OctoberInstall.php


示例13: decryptedAttribute

 /**
  * Return the decrypted value of an attribute's encrypted value.
  *
  * @param string    $value
  * @param Encrypter $cipher
  *
  * @return string
  */
 public function decryptedAttribute($value, $cipher)
 {
     return $cipher->decrypt(str_replace($this->getElocryptPrefix(), '', $value));
 }
开发者ID:delatbabel,项目名称:elocryptfive,代码行数:12,代码来源:ReEncrypt.php


示例14: etuGuaranteeSubmit

 /**
  *
  * @return Response
  */
 public function etuGuaranteeSubmit()
 {
     $input = Request::only(['guarantee', 'cgv']);
     // Check errors
     $oldGuarantee = EtuUTT::student()->guaranteePayment && in_array(EtuUTT::student()->guaranteePayment->state, ['paid', 'returned', 'refunded']) ? 1 : 0;
     $guarantee = $input['guarantee'] ? 1 : 0;
     if ($input['guarantee'] && $oldGuarantee) {
         return Redirect::back()->withError('Vous ne pouvez pas payer deux fois la caution')->withInput();
     }
     if (!$input['cgv']) {
         return Redirect::back()->withError('Vous devez accepter les conditions générales de vente')->withInput();
     }
     // Calculate amount
     $amount = $guarantee * Config::get('services.wei.guaranteePrice') * 100;
     // Create payment
     $payment = new Payment(['type' => 'guarantee', 'mean' => 'etupay', 'amount' => $amount, 'state' => 'started']);
     $payment->save();
     // Save paiement in user object
     $user = EtuUTT::student();
     if ($guarantee) {
         $user->guarantee_payment = $payment->id;
     }
     $user->save();
     // Calculate EtuPay Payload
     $crypt = new Encrypter(base64_decode(Config::get('services.etupay.key')), 'AES-256-CBC');
     $payload = $crypt->encrypt(json_encode(['type' => 'authorisation', 'amount' => $amount, 'client_mail' => $user->email, 'firstname' => $user->first_name, 'lastname' => $user->last_name, 'description' => 'Formulaire de dépôt de la caution du weekend d\'intégration', 'articles' => [['name' => 'Caution du Week-end d\'intégration', 'price' => Config::get('services.wei.guaranteePrice') * 100, 'quantity' => $guarantee]], 'service_data' => $payment->id]));
     return Redirect(Config::get('services.etupay.uri.initiate') . '?service_id=' . Config::get('services.etupay.id') . '&payload=' . $payload);
 }
开发者ID:ungdev,项目名称:integration-UTT,代码行数:32,代码来源:WEIController.php


示例15: getKey

 /**
  * Get the encryption key.
  *
  * @return string
  * @static
  */
 public static function getKey()
 {
     return \Illuminate\Encryption\Encrypter::getKey();
 }
开发者ID:Dimimo,项目名称:Booklet,代码行数:10,代码来源:_ide_helper.php


示例16: 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


示例17: 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


示例18: 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


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Events\Dispatcher类代码示例发布时间:2022-05-23
下一篇:
PHP Schema\MySqlBuilder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap