mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
644 B
PHP
37 lines
644 B
PHP
<?php
|
|
|
|
namespace App\Util\HttpSignatures;
|
|
|
|
class HmacAlgorithm implements AlgorithmInterface
|
|
{
|
|
/** @var string */
|
|
private $digestName;
|
|
|
|
/**
|
|
* @param string $digestName
|
|
*/
|
|
public function __construct($digestName)
|
|
{
|
|
$this->digestName = $digestName;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function name()
|
|
{
|
|
return sprintf('hmac-%s', $this->digestName);
|
|
}
|
|
|
|
/**
|
|
* @param string $key
|
|
* @param string $data
|
|
*
|
|
* @return string
|
|
*/
|
|
public function sign($secret, $data)
|
|
{
|
|
return hash_hmac($this->digestName, $data, $secret, true);
|
|
}
|
|
}
|