Elgg  Version 3.0
HmacFactory.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Security;
3 
4 use ElggCrypto;
6 
10 class HmacFactory {
11 
15  private $site_secret;
16 
20  private $crypto;
21 
28  public function __construct(SiteSecret $secret, ElggCrypto $crypto) {
29  $this->site_secret = $secret;
30  $this->crypto = $crypto;
31  }
32 
42  public function getHmac($data, $algo = 'sha256', $key = '') {
43  if (!$key) {
44  $key = $this->site_secret->get(true);
45  }
46  return new Hmac($key, [$this->crypto, 'areEqual'], $data, $algo);
47  }
48 }
Manages a site-specific secret key, encoded as a 32 byte string "secret".
Definition: SiteSecret.php:24
if(elgg_trigger_plugin_hook('usersettings:save', 'user', $hooks_params, true)) foreach($request->validation() ->all() as $item) $data
Definition: save.php:57
getHmac($data, $algo= 'sha256', $key= '')
Get an HMAC token builder/validator object.
Definition: HmacFactory.php:42
Component for creating HMAC tokens.
Definition: Hmac.php:7
__construct(SiteSecret $secret, ElggCrypto $crypto)
Constructor.
Definition: HmacFactory.php:28
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
Provides a factory for HMAC objects.
Definition: HmacFactory.php:10