Completed
Push — master ( 5b2039...ff2518 )
by Marcel
06:16
created

HashCalculator::hmac()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace UMA\Psr7Hmac\Internal;
4
5
use UMA\Psr7Hmac\Specification;
6
7
class HashCalculator
8
{
9
    /**
10
     * @param string $data The string to be signed
11
     * @param string $key  The secret with which to sign it
12
     *
13
     * @return string A base64-encoded SHA256 hash (so it is guaranteed to be 44 bytes long)
14
     */
15 105
    public function hmac($data, $key)
16
    {
17 105
        return base64_encode(hash_hmac(Specification::HASH_ALGORITHM, $data, $key, true));
18
    }
19
}
20