noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
otp.class.php
Go to the documentation of this file.
1<?php
2
3namespace Noalyss;
4
5/*
6 * This file is part of NOALYSS.
7 *
8 * NOALYSS is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NOALYSS is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NOALYSS; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22// Copyright Author Dany De Bontridder danydb@aevalys.eu 22/10/23
23
24
25/**
26 * @file
27 * @brief class using OTP
28 *
29 */
30
31/**
32 * @brief generate OTP
33 */
34use chillerlan\Authenticator\{
35 Authenticator,
36 AuthenticatorOptions
37};
38use chillerlan\Authenticator\Authenticators\AuthenticatorInterface;
39
40class OTP {
41
43
44 function __construct() {
45 $options = new AuthenticatorOptions;
46 $options->secret_length = 32;
47 $options->algorithm = AuthenticatorInterface::ALGO_SHA512;
48 $options->digits=6;
49 $this->authenticator = new Authenticator($options);
50 }
51 /**
52 * @brief build a secret key and returns it
53 * @return string random string of 32 char
54 */
55 function build_secret() {
56
57 $secret = $this->authenticator->createSecret();
58 return $secret;
59
60 }
61
62 /**
63 * @brief compute a code for auth. for the user passed in parameter
64 * @param $secret (string) secret stored in AC_USER
65 */
67 {
68
69 $this->authenticator->setSecret($secret);
70 return $this->authenticator->code();
71 }
72 public function get_authenticator() {
74 }
75
77 $this->authenticator = $authenticator;
78 return $this;
79 }
80
81
82}
get_authenticator()
Definition otp.class.php:72
compute_code($secret)
compute a code for auth.
Definition otp.class.php:66
set_authenticator($authenticator)
Definition otp.class.php:76
build_secret()
build a secret key and returns it
Definition otp.class.php:55