/**
  * 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;
 }
 /**
  * Decrypt the value.
  *
  * @return string
  */
 public function decrypted()
 {
     if (!($value = $this->object->getValue())) {
         return null;
     }
     return $this->encrypter->decrypt($value);
 }
Exemplo n.º 3
0
 /**
  * Decrypt the given cookie value.
  *
  * @param  string      $value
  * @return mixed|null
  */
 protected function decrypt($value)
 {
     try {
         return $this->encrypter->decrypt($value);
     } catch (\Exception $e) {
         return null;
     }
 }
Exemplo n.º 4
0
 /**
  * Decrypt the cookies on the request.
  *
  * @param  \Symfony\Component\HttpFoundation\Request  $request
  * @return \Symfony\Component\HttpFoundation\Request
  */
 protected function decrypt(Request $request)
 {
     foreach ($request->cookies as $key => $c) {
         try {
             $request->cookies->set($key, $this->encrypter->decrypt($c));
         } catch (DecryptException $e) {
             $request->cookies->set($key, null);
         }
     }
     return $request;
 }
 /**
  * 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);
 }
 /**
  * Retrieve an item from the cache by key.
  *
  * @param  string  $key
  * @return mixed
  */
 public function get($key)
 {
     $key = $this->prefix . $key;
     $cache = $this->getCacheCollection()->where('key', $key)->first();
     // If we have a cache record we will check the expiration time against current
     // time on the system and see if the record has expired. If it has, we will
     // remove the records from the database collection so it isn't returned again.
     if (!is_null($cache)) {
         if (time() >= $cache['expiration']->sec) {
             return $this->forget($key);
         }
         return $this->encrypter->decrypt($cache['value']);
     }
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 /**
  * Retrieve an item from the cache by key.
  *
  * @param  string  $key
  * @return mixed
  */
 public function get($key)
 {
     $prefixed = $this->prefix . $key;
     $cache = $this->table()->where('key', '=', $prefixed)->first();
     // If we have a cache record we will check the expiration time against current
     // time on the system and see if the record has expired. If it has, we will
     // remove the records from the database table so it isn't returned again.
     if (!is_null($cache)) {
         if (is_array($cache)) {
             $cache = (object) $cache;
         }
         if (time() >= $cache->expiration) {
             return $this->forget($key);
         }
         return $this->encrypter->decrypt($cache->value);
     }
 }
Exemplo n.º 11
0
 /**
  * Decrypt an array based cookie.
  *
  * @param  array  $cookie
  * @return array
  */
 protected function decryptArray(array $cookie)
 {
     $decrypted = array();
     foreach ($cookie as $key => $value) {
         $decrypted[$key] = $this->encrypter->decrypt($value);
     }
     return $decrypted;
 }
Exemplo n.º 12
0
 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  array  $credentials
  * @return bool
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     $plain = $credentials['password'];
     if ($this->encryptedPassword) {
         return $plain == $this->encrypter->decrypt($user->getAuthPassword());
     }
     return $this->hasher->check($plain, $user->getAuthPassword());
 }
 /**
  * Marshal out the pushed job and payload.
  *
  * @throws \Exception
  * @return object
  */
 protected function marshalPushedJob()
 {
     $id = $this->request->header('x-zend-job-id');
     $payload = $this->request->input("payload");
     if (empty($payload)) {
         throw new \Exception("Payload Not Found.");
     }
     $body = $this->crypt->decrypt($payload);
     return (object) ['id' => $id, 'body' => $body, 'pushed' => true];
 }
 /**
  * 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;
 }
Exemplo n.º 15
0
 /**
  * Marshal out the pushed job and payload.
  *
  * @return StdClass
  */
 protected function marshalPushedJob()
 {
     $r = $this->request;
     $body = $this->crypt->decrypt($r->getContent());
     return (object) array('id' => $r->header('iron-message-id'), 'body' => $body, 'pushed' => true);
 }
Exemplo n.º 16
0
 /**
  * To Decrypt the given Crypt data by Secret Key
  *
  * @param string $coded_string Encoded Data
  * @return string Raw Data
  */
 public static function decrypt($coded_string)
 {
     $decode = new Encrypter(self::$enc_key);
     if (!$coded_string) {
         return array();
     }
     return $decode->decrypt($coded_string);
 }
Exemplo n.º 17
0
<?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();
function getAndDecryptPayload($payload)
{
    $crypt = new Encrypter(Config::get('app.key'));
    $payload = $crypt->decrypt($payload);
    return json_decode(json_encode($payload), FALSE);
}
 /**
  * Fire the Closure based queue job.
  *
  * @param  \Illuminate\Queue\Jobs\Job  $job
  * @param  array  $data
  * @return void
  */
 public function fire($job, $data)
 {
     $closure = unserialize($this->crypt->decrypt($data['closure']));
     $closure($job);
 }
Exemplo n.º 20
0
 /**
  * @param $data
  * @return string
  */
 public function decrypt($data)
 {
     return $this->encrypter->decrypt($data);
 }
Exemplo n.º 21
0
 /**
  * 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));
 }
Exemplo n.º 22
0
 /**
  * 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);
 }
Exemplo n.º 23
0
 /**
  * @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());
 }
Exemplo n.º 24
0
function decryptPayload($payload)
{
    $crypt = new Encrypter(getenv('IRON_ENCRYPTION_KEY'));
    $payload = $crypt->decrypt($payload);
    return json_decode(json_encode($payload), FALSE);
}