ManaPHP\Authentication\Token\Adapter\Mwt::encode PHP Method

encode() public method

public encode ( ) : string
return string
    public function encode()
    {
        $data = [];
        $data['SALT'] = mt_rand(0, 2147483647);
        $data['EXP'] = $this->_ttl + time();
        foreach ($this->_fields as $k => $v) {
            $data[$v] = $this->{is_int($k) ? $v : $k};
        }
        $payload = rtrim(base64_encode(json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)), '=');
        $hash = rtrim(base64_encode(md5($this->_type . $payload . $this->_keys[0], true)), '=');
        return strtr($this->_type . '.' . $payload . '.' . $hash, '+/', '-_');
    }