radarrplexorganizrnginxsonarrdashboardembycouchpotatonzbgetbookmarkapplication-dashboardmuximuxlandingpagestartpagelandinghtpcserverhomepagesabnzbdheimdall
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
975 B
42 lines
975 B
<?php
|
|
/* ===========================================================================
|
|
* Copyright (c) 2018 Zindex Software
|
|
*
|
|
* Licensed under the MIT License
|
|
* =========================================================================== */
|
|
|
|
namespace Opis\Closure;
|
|
|
|
class SecurityProvider implements ISecurityProvider
|
|
{
|
|
/** @var string */
|
|
protected $secret;
|
|
|
|
/**
|
|
* SecurityProvider constructor.
|
|
* @param string $secret
|
|
*/
|
|
public function __construct($secret)
|
|
{
|
|
$this->secret = $secret;
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function sign($closure)
|
|
{
|
|
return array(
|
|
'closure' => $closure,
|
|
'hash' => base64_encode(hash_hmac('sha256', $closure, $this->secret, true)),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function verify(array $data)
|
|
{
|
|
return base64_encode(hash_hmac('sha256', $data['closure'], $this->secret, true)) === $data['hash'];
|
|
}
|
|
}
|