Signer::getMethod()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
1
<?php namespace nyx\auth\interfaces;
2
3
/**
4
 * Signer Interface
5
 *
6
 * Security note on Signers: The hashers in this component are *absolutely not* meant for hashing passwords.
7
 * They are used for generating signatures of messages, which in turn are used for verifying the authenticity
8
 * of those messages, but are not intended to be used outside of that purpose.
9
 *
10
 * @package     Nyx\Auth
11
 * @version     0.1.0
12
 * @author      Michal Chojnacki <[email protected]>
13
 * @copyright   2012-2017 Nyx Dev Team
14
 * @link        https://github.com/unyx/nyx
15
 */
16
interface Signer
17
{
18
    /**
19
     * Generates a signature of the payload using the provided key.
20
     *
21
     * @param   string              $payload    The payload to create a signature for.
22
     * @param   string|Credentials  $key        The key in form of a string or a Credentials instance. If a Credentials
23
     *                                          instance is given, its *secret* (private part) will be used.
24
     * @return  string                          The signature.
25
     */
26
    public function sign(string $payload, $key) : string;
27
28
    /**
29
     * Verifies that the signature of the payload generated using the provided key matches the expected signature.
30
     *
31
     * @param   string              $expected   The expected signature.
32
     * @param   $payload            $payload    The payload that should form the verified signature.
0 ignored issues
show
Documentation introduced by
The doc-type $payload could not be parsed: Unknown type name "$payload" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
33
     * @param   string|Credentials  $key        The key in form of a string or a Credentials instance. If a Credentials
34
     *                                          instance is given, its *id* (public part) will be used.
35
     * @return  bool                            True when the signature could be verified, false otherwise.
36
     */
37
    public function verify(string $expected, string $payload, $key) : bool;
38
39
    /**
40
     * Returns the name/identifier of the hashing method this Signer uses.
41
     *
42
     * @return  string
43
     */
44
    public function getMethod() : string;
45
46
    /**
47
     * Returns the name/identifier of the hashing algorithm this Signer uses.
48
     *
49
     * @return  string
50
     */
51
    public function getAlgorithm() : string;
52
}
53