라라벨 EncryptedStore

1 개요[ | ]

라라벨 EncryptedStore
<?php

namespace Illuminate\Session;

use SessionHandlerInterface;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;

class EncryptedStore extends Store
{
    protected $encrypter;

    public function __construct($name, SessionHandlerInterface $handler, EncrypterContract $encrypter, $id = null)
    {
        $this->encrypter = $encrypter;
        parent::__construct($name, $handler, $id);
    }

    protected function prepareForUnserialize($data)
    {
        try {
            return $this->encrypter->decrypt($data);
        } catch (DecryptException $e) {
            return json_encode([]);
        }
    }

    protected function prepareForStorage($data)
    {
        return $this->encrypter->encrypt($data);
    }

    public function getEncrypter()
    {
        return $this->encrypter;
    }
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}