コード例 #1
0
ファイル: Guard.php プロジェクト: yashb/generator
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
ファイル: DatabaseStore.php プロジェクト: Thomvh/turbine
 /**
  * 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'));
     }
 }
コード例 #5
0
 /**
  * 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);
     }
 }
コード例 #6
0
 /**
  * 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);
 }
コード例 #7
0
ファイル: CookieJar.php プロジェクト: lenninsanchez/donadores
 /**
  * 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);
 }
コード例 #8
0
 /**
  * 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;
 }
コード例 #9
0
ファイル: PhPsst.php プロジェクト: felixsand/phpsst
 /**
  * @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;
 }
コード例 #10
0
ファイル: InitCommand.php プロジェクト: donepm/cli-client
 /**
  * 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;
 }
コード例 #11
0
 /**
  * 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);
 }
コード例 #12
0
ファイル: index.php プロジェクト: aaemnnosttv/Torch
<?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();
コード例 #13
0
 /**
  *
  * @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);
 }
コード例 #14
0
 /**
  * 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;
 }
コード例 #15
0
ファイル: Cart.php プロジェクト: flycartinc/cart
 /**
  * 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);
 }
コード例 #16
0
ファイル: PHPCasProvider.php プロジェクト: jcrowe206/php-cas
 /**
  * Encrypt the provided data
  *
  * @param $data
  */
 public function encrypt($data)
 {
     return $this->encrypter->encrypt($data);
 }
コード例 #17
0
ファイル: ReEncrypt.php プロジェクト: delatbabel/elocryptfive
 /**
  * Return the encrypted value of an attribute's value.
  *
  * @param string    $value
  * @param Encrypter $cipher
  *
  * @return string
  */
 public function encryptedAttribute($value, $cipher)
 {
     return $this->getElocryptPrefix() . $cipher->encrypt($value);
 }
コード例 #18
0
ファイル: IronQueue.php プロジェクト: trangunghoa/l4cms
 /**
  * Create a payload string from the given job and data.
  *
  * @param  string  $job
  * @param  mixed   $data
  * @return string
  */
 protected function createPayload($job, $data = '')
 {
     return $this->crypt->encrypt(parent::createPayload($job, $data));
 }
コード例 #19
0
 /**
  * Modify the value.
  *
  * @param $value
  * @return mixed
  */
 public function modify($value)
 {
     return $this->encrypter->encrypt($value);
 }
コード例 #20
0
ファイル: _ide_helper.php プロジェクト: satriashp/tour
 /**
  * Encrypt the given value.
  *
  * @param string $value
  * @return string 
  * @throws \Illuminate\Contracts\Encryption\EncryptException
  * @static 
  */
 public static function encrypt($value)
 {
     return \Illuminate\Encryption\Encrypter::encrypt($value);
 }
コード例 #21
0
ファイル: IronQueue.php プロジェクト: flelievre/EasyVisit
 /**
  * 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);
     return $this->iron->postMessage($this->getQueue($queue), $payload, $options)->id;
 }
コード例 #22
0
ファイル: RunWorker.php プロジェクト: mrtnsn/laraworker
 protected function encryptPayload($payload)
 {
     $crypt = new Encrypter(Config::get('app.key'));
     return $crypt->encrypt($payload);
 }