mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-27 16:53:17 +00:00
36 lines
644 B
PHP
Executable file
36 lines
644 B
PHP
Executable file
<?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);
|
|
}
|
|
}
|