本文整理汇总了PHP中Illuminate\Contracts\Encryption\Encrypter::decrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP Encrypter::decrypt方法的具体用法?PHP Encrypter::decrypt怎么用?PHP Encrypter::decrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Encryption\Encrypter
的用法示例。
在下文中一共展示了Encrypter::decrypt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tokensMatch
/**
* Determine if the session and input CSRF tokens match.
*
* @param \Illuminate\Http\Request $request
* @return bool
*/
protected function tokensMatch($request)
{
$token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
if (!$token && ($header = $request->header('X-XSRF-TOKEN'))) {
$token = $this->encrypter->decrypt($header);
}
return Str::equals($request->session()->token(), $token);
}
示例2: decryptArray
/**
* 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;
}
示例3: prepareForUnserialize
/**
* Prepare the raw string data from the session for unserialization.
*
* @param string $data
* @return string
*/
protected function prepareForUnserialize($data)
{
try {
return $this->encrypter->decrypt($data);
} catch (DecryptException $e) {
return json_encode([]);
}
}
示例4: onReady
/**
* Fired just before building.
*
* @param Encrypter $encrypter
* @param Request $request
*/
public function onReady(Encrypter $encrypter, Request $request)
{
if ($code = $request->get('code')) {
array_set($this->parameters, 'code', $encrypter->decrypt($code));
}
if ($email = $request->get('email')) {
array_set($this->parameters, 'email', $encrypter->decrypt($email));
}
}
示例5: tokensMatch
/**
* Determine if the session and input CSRF tokens match.
*
* @param \Illuminate\Http\Request $request
* @return bool
*/
protected function tokensMatch($request)
{
// Get tokens from session and the request
$sessionToken = $request->session()->token();
$token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
if (!$token && ($header = $request->header('X-XSRF-TOKEN'))) {
$token = $this->encrypter->decrypt($header);
}
if (!is_string($sessionToken) || !is_string($token)) {
return false;
}
// Validate them
return hash_equals((string) $request->session()->token(), (string) $token);
}
示例6: handle
/**
* Handle the command.
*
* @param UserRepositoryInterface $users
* @param UserActivator $activator
* @param Encrypter $encrypter
* @param Request $request
* @return bool
*/
public function handle(UserRepositoryInterface $users, UserActivator $activator, Encrypter $encrypter, Request $request)
{
$code = $request->get('code');
$email = $request->get('email');
if (!$code || !$email) {
return false;
}
$code = $encrypter->decrypt($code);
$email = $encrypter->decrypt($email);
if (!($user = $users->findByEmail($email))) {
return false;
}
return $activator->activate($user, $code);
}
示例7: date
function it_fails_with_string(Encrypter $encrypter, Request $request)
{
$time = date("Y-m-d H:i:s", strtotime("30 seconds ago"));
$request->get('_guard_opened')->willReturn($time);
$encrypter->decrypt($time)->willReturn($time);
$this->validate($request)->shouldReturn(false);
}
示例8: validate
/**
* Validate the request.
*
* @param \Illuminate\Http\Request $request
* @param array $params
* @return bool
*/
public function validate($request, $params = [])
{
$this->params = $params;
try {
$timeOpened = $this->encrypter->decrypt($request->get('_guard_opened'));
} catch (DecryptException $e) {
return false;
}
if (!is_numeric($timeOpened)) {
return false;
}
$timeElapsed = time() - $timeOpened;
$tooFast = $timeElapsed < $this->getMinTime();
$tooSlow = $timeElapsed > $this->getMaxTime();
return !$tooFast && !$tooSlow;
}
示例9: decryptPayload
/**
* Attempt to decrypt payload.
*/
protected function decryptPayload()
{
try {
$decrypted = $this->encrypter->decrypt($this->encryptedValue);
$this->decryptedValue = json_decode($decrypted);
} catch (\Exception $e) {
throw new Exceptions\InvalidEncryptionFormat($e->getMessage());
}
}
示例10: get
/**
* 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) {
$this->forget($key);
return;
}
return $this->encrypter->decrypt($cache->value);
}
}
示例11: decryptArray
/**
* Decrypt an array based cookie.
*
* @param array $cookie
* @return array
*/
protected function decryptArray(array $cookie)
{
$decrypted = [];
foreach ($cookie as $key => $value) {
if (is_string($value)) {
$decrypted[$key] = $this->encrypter->decrypt($value);
}
}
return $decrypted;
}
示例12: incrementOrDecrement
/**
* Increment or decrement an item in the cache.
*
* @param string $key
* @param mixed $value
* @param \Closure $callback
* @return void
*/
protected function incrementOrDecrement($key, $value, Closure $callback)
{
$prefixed = $this->prefix . $key;
$cache = $this->table()->where('key', $prefixed)->lockForUpdate()->first();
if (!is_null($cache)) {
$current = $this->encrypter->decrypt($cache->value);
if (is_numeric($current)) {
$this->table()->where('key', $prefixed)->update(['value' => $this->encrypter->encrypt($callback($current))]);
}
}
}
示例13: tokensMatch
/**
* @param \Illuminate\Http\Request $request
*
* @return bool
*/
protected function tokensMatch($request)
{
$sessionToken = $request->session()->token();
$token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
if (!$token && ($header = $request->header('X-XSRF-TOKEN'))) {
$token = $this->encrypter->decrypt($header);
}
if (!is_string($sessionToken) || !is_string($token)) {
return false;
}
return hash_equals($sessionToken, $token);
}
示例14: getActivate
/**
* Activate a user by token
* @param string $token
* @param Request $request
* @param Events $events
* @return Illuminate\Http\Response
*/
public function getActivate(Encrypter $encrypter, Request $request, Events $events, $token)
{
try {
$data = json_decode($encrypter->decrypt($token));
if (is_object($data) && isset($data->id) && is_numeric($data->id) && isset($data->expires) && with(new Carbon(date('Y-m-d H:i:s', $data->expires)))->gt(Carbon::now())) {
$user = $this->activateUser($data->id);
$events->fire(new UserActivated($user));
return $this->userWasActivated($data->id);
} else {
throw new Exception("Invalid token");
}
} catch (Exception $e) {
return $this->userWasNotActivated();
}
}
示例15: incrementOrDecrement
/**
* Increment or decrement an item in the cache.
*
* @param string $key
* @param mixed $value
* @param \Closure $callback
* @return int|bool
*/
protected function incrementOrDecrement($key, $value, Closure $callback)
{
return $this->connection->transaction(function () use($key, $value, $callback) {
$prefixed = $this->prefix . $key;
$cache = $this->table()->where('key', $prefixed)->lockForUpdate()->first();
if (is_null($cache)) {
return false;
}
$current = $this->encrypter->decrypt($cache->value);
$new = $callback($current, $value);
if (!is_numeric($current)) {
return false;
}
$this->table()->where('key', $prefixed)->update(['value' => $this->encrypter->encrypt($new)]);
return $new;
});
}