· 5 years ago · Jun 20, 2020, 04:10 PM
1class googleAuthLibrary extends GoogleAuthenticator
2{
3 public function getSecretKey()
4 {
5 $secretKey = $this->generateSecret();
6
7 return $secretKey;
8 }
9
10 public function getQRLink($username, $hostname, $secretKey)
11 {
12 $url = 'https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=';
13
14 $qrCode = 'otpauth://totp/'.$username.'@'.$hostname.'?secret='.$secretKey;
15
16 $url = $url.$qrCode;
17
18 return $url;
19 }
20
21 public function getAuthCode($secretKey)
22 {
23 $authCode =$this->getCode($secretKey);
24
25 return $authCode;
26 }
27}