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


PHP Encrypter::encrypt方法代码示例

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


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

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

示例2: pushRaw

 /**
  * Push a raw payload onto the queue.
  *
  * @param  string $payload
  * @param  string $queue
  * @param  array $options
  * @return mixed
  */
 public function pushRaw($payload, $queue = null, array $options = array())
 {
     $payload = $this->crypt->encrypt($payload);
     /** @noinspection PhpUndefinedClassInspection */
     $queue = new \ZendJobQueue();
     /** @noinspection PhpUndefinedMethodInspection */
     $jobIdentifier = $queue->createHttpJob($this->callbackUrl, ["payload" => $payload], $options);
     return $jobIdentifier;
 }
开发者ID:orlissenberg,项目名称:laravel-zendserver-pushqueue,代码行数:17,代码来源:ZendJobQueue.php

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

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

示例5: 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 = new \MongoDate($this->getTime() + $minutes * 60);
     $data = array('expiration' => $expiration, 'key' => $key, 'value' => $value);
     $item = $this->getCacheCollection()->where('key', $key)->first();
     if (is_null($item)) {
         $this->getCacheCollection()->insert($data);
     } else {
         $this->getCacheCollection()->where('key', $key)->update($data);
     }
 }
开发者ID:vansteen,项目名称:laravel-mongodb-cache,代码行数:24,代码来源:MongodbStore.php

示例6: make

 /**
  * Create a new cookie instance.
  *
  * @param  string  $name
  * @param  string  $value
  * @param  int     $minutes
  * @return Symfony\Component\HttpFoundation\Cookie
  */
 public function make($name, $value, $minutes = 0)
 {
     extract($this->defaults);
     // Once we calculate the time we can encrypt the message. All cookies will be
     // encrypted using the Illuminate encryption component and will have a MAC
     // assigned to them by the encrypter to make sure they remain authentic.
     $time = $minutes == 0 ? 0 : time() + $minutes * 60;
     $value = $this->encrypter->encrypt($value);
     return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly);
 }
开发者ID:defra91,项目名称:levecchiecredenze.it,代码行数:18,代码来源:CookieJar.php

示例7: make

 /**
  * Create a new cookie instance.
  *
  * @param  string  $name
  * @param  string  $value
  * @param  int     $minutes
  * @param  string  $path
  * @param  string  $domain
  * @param  bool    $secure
  * @param  bool    $httpOnly
  * @return \Symfony\Component\HttpFoundation\Cookie
  */
 public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
 {
     list($path, $domain) = $this->getPathAndDomain($path, $domain);
     // Once we calculate the time we can encrypt the message. All cookies will be
     // encrypted using the Illuminate encryption component and will have a MAC
     // assigned to them by the encrypter to make sure they remain authentic.
     $time = $minutes == 0 ? 0 : time() + $minutes * 60;
     $value = $this->encrypter->encrypt($value);
     return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly);
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:22,代码来源:CookieJar.php

示例8: encrypt

 /**
  * Criptografa os dados.
  *
  * @param  array $data
  * @return array
  */
 public function encrypt(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 (in_array($key, $this->getEncryptable())) {
             $data[$key] = $encrypter->encrypt($value);
         }
     }
     return $data;
 }
开发者ID:resultsystems,项目名称:protectall,代码行数:21,代码来源:BaseCryptRepository.php

示例9: store

 /**
  * @param string $password
  * @param int $ttl
  * @param int $views
  * @return string
  */
 public function store($password, $ttl = 3600, $views = 1)
 {
     if (empty($password)) {
         throw new \InvalidArgumentException('The password has to be set');
     }
     $ttl = (int) $ttl;
     if ($ttl < 1) {
         throw new \InvalidArgumentException('TTL has to be higher than 0');
     }
     $views = (int) $views;
     if ($views < 1) {
         throw new \InvalidArgumentException('Views has to be highter han 0');
     }
     $id = uniqid();
     $key = $this->generateKey();
     $encrypter = new Encrypter($key, $this->cipher);
     $this->storage->store(new Password($id, $encrypter->encrypt($password), $ttl + time(), $views));
     return $id . ';' . $key;
 }
开发者ID:felixsand,项目名称:phpsst,代码行数:25,代码来源:PhPsst.php

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

示例11: serializeToken

 /**
  * Returns serialized token.
  *
  * @param AuthToken $token
  * @return string
  */
 public function serializeToken(AuthToken $token)
 {
     $payload = array('id' => $token->getAuthIdentifier(), 'key' => $token->getPublicKey());
     return $this->encrypter->encrypt($payload);
 }
开发者ID:bytesflipper,项目名称:laravel-auth-token,代码行数:11,代码来源:AbstractAuthTokenProvider.php

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

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

示例14: serializeToken

 /**
  * Returns serialized token.
  *
  * @param AuthToken $token
  * @return string
  */
 public function serializeToken(AuthToken $token)
 {
     $payload = $this->encrypter->encrypt(array('id' => $token->getAuthIdentifier(), 'key' => $token->getPublicKey(), 'userAgent' => $token->getUserAgent()));
     $payload = str_replace(array('+', '/', '\\r', '\\n', '='), array('-', '_'), $payload);
     return $payload;
 }
开发者ID:tfleet,项目名称:tf-auth-token,代码行数:12,代码来源:AbstractAuthTokenProvider.php

示例15: encrypt

 /**
  * To Encrypt the given data with Encryption package by Secret Key
  *
  * @param string $string Raw Data
  * @return string Encoded Data
  */
 public static function encrypt($string)
 {
     $encoder = new Encrypter(self::$enc_key);
     if (!$string) {
         return array();
     }
     return $encoder->encrypt($string);
 }
开发者ID:flycartinc,项目名称:cart,代码行数:14,代码来源:Cart.php


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