本文整理汇总了PHP中Illuminate\Contracts\Encryption\Encrypter类的典型用法代码示例。如果您正苦于以下问题:PHP Encrypter类的具体用法?PHP Encrypter怎么用?PHP Encrypter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Encrypter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: time
function it_returns_the_timer_html(Encrypter $encrypter)
{
$time = time();
$encrypter->encrypt($time)->willReturn($time);
$html = (require __DIR__ . "/../../../src/Html/templates/timer.php");
$this->html()->shouldReturn($html);
}
示例3: handle
/**
* Handle the command.
*
* @param Repository $config
* @param Encrypter $encrypter
* @return string
*/
public function handle(Repository $config, Encrypter $encrypter)
{
$email = $encrypter->encrypt($this->user->getEmail());
$code = $encrypter->encrypt($this->user->getResetCode());
$query = "?email={$email}&code={$code}&redirect={$this->redirect}";
return $config->get('anomaly.module.users::paths.reset') . $query;
}
示例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: handle
/**
* Execute the job.
*
* @param Mailer $mailer
* @return void
*/
public function handle(Mailer $mailer, Encrypter $encrypter)
{
app()->setLocale($this->locale);
$token = $encrypter->encrypt(json_encode(['id' => $this->user->getKey(), 'expires' => time() + 3600 * 72]));
$user = $this->user;
$mailer->send('core::emails.activate', compact('user', 'token'), function ($message) use($user) {
$message->to($user->email);
$message->subject(trans('core::auth.emails.activate.subject'));
});
}
示例6: locationUpdate
/**
* Fetch the list of Locations
*
* @Get("/", as="AdminLocationsIndex")
*/
public function locationUpdate($id, Encrypter $encrypter)
{
//echo $id;
$token = $encrypter->encrypt(csrf_token());
//$locations = DB::table('locations')->where('id', '=', $id)->first();
$query = "SELECT ld.`id` AS `location_id` , ld.`name` AS `location` , ld.`slug` AS `slug` , IF( la.`id` = ld.`id` , '', la.`id` ) AS `parent_id` , IF( la.`id` = ld.`id` , '', la.`name` ) AS `parent` , CAST( ld.type AS CHAR ) AS `location_type`\n FROM locations_tree AS `lt`\n INNER JOIN locations AS `ld` ON lt.`descendant` = ld.`id`\n INNER JOIN locations AS `la` ON lt.`ancestor` = la.`id`\n WHERE (lt.`length` =1 OR ld.`type` = 'Country') AND ld.id = '{$id}'";
$locations = DB::select($query);
/*print_r($locations);
echo $locations['0']->location_id;
exit;*/
return view('admin.settings.locationsupdate', ['_token' => $token, 'locations' => $locations]);
//return response()->json($locations->fetch($request->all()));
}
示例7: 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);
}
示例8: 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();
}
}
示例9: index
/**
* Display a listing of the resource.
*
* @param Encrypter $encrypter
* @param $hash
* @return Response
* @throws Exception
*/
public function index(Encrypter $encrypter, $hash)
{
try {
$params = $encrypter->decrypt($hash);
$project = $this->projectRepository->find($params['project']);
$user = $project->users->find($params['user']);
if (is_null($user)) {
throw new Exception('the user was not found');
}
$sourceClass = app()->make('Knoters\\Services\\Sources\\' . ucfirst($project->type->name) . 'Service');
$video = $sourceClass->getVideo($project->video_id);
$this->fractal->setSerializer(new ArraySerializer());
JavaScriptFacade::put(['user' => $this->fractal->createData(new Item($user, new UserTransformer()))->toArray(), 'project' => $this->fractal->createData(new Item($project, new ProjectTransformer()))->toArray()]);
return view('editor', ['video' => $video, 'project' => $project]);
} catch (Exception $e) {
throw $e;
$this->errorResponse($e);
}
}
示例10: getData
/**
* The data that is needed in the view
*
* @return mixed
*/
public function getData()
{
$params = ['project' => $this->user->pivot->project_id, 'user' => $this->user->id];
$userHash = $this->encrypter->encrypt($params);
$url = env('BASE_URL', 'http://knoters.com') . '/editor/' . $userHash;
return ['url' => $url];
}
示例11: 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(urldecode($value));
}
return $decrypted;
}
示例12: 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);
}
示例13: 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);
}
示例14: 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;
}
示例15: encrypt
/**
* 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 => $cookie) {
$response->headers->setCookie($this->duplicate($cookie, $this->encrypter->encrypt($cookie->getValue())));
}
return $response;
}