TotpEncoderInterface
last analyzed

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
generateBase32RandomKey() 0 1 ?
toBase32() 0 1 ?
fromBase32() 0 1 ?
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/2fa-library project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\TwoFA\Contracts;
13
14
use Da\TwoFA\Exception\InvalidCharactersException;
15
16
interface TotpEncoderInterface
17
{
18
    /**
19
     * Generate a digit secret key in base32 format.
20
     *
21
     * @param int    $length
22
     * @param string $prefix
23
     *
24
     * @return string
25
     */
26
    public function generateBase32RandomKey(int $length = 16, string $prefix = ''): string;
27
28
    /**
29
     * Encode a string to Base32.
30
     *
31
     * @param string $value
32
     *
33
     * @return string
34
     */
35
    public function toBase32(string $value): string;
36
37
    /**
38
     * Decodes a base32 string into a binary string.
39
     *
40
     * @param string $value
41
     *
42
     * @throws InvalidCharactersException
43
     *
44
     * @return string
45
     */
46
    public function fromBase32(string $value): string;
47
}
48