1
0
Fork 0
pixelfed/app/Util/HTTPSignatures/HmacAlgorithm.php

37 lines
644 B
PHP
Raw Normal View History

2018-11-19 03:33:10 +00:00
<?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);
}
}