PHP Класс PHPGangsta_GoogleAuthenticator

Автор: Michael Kliewe
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_codeLength

Открытые методы

Метод Описание
createSecret ( integer $secretLength = 16 ) : string Create new secret.
getCode ( string $secret, integer | null $timeSlice = null ) : string Calculate the code, with given secret and point in time.
getQRCodeGoogleUrl ( string $name, string $secret, string $title = null, array $params = [] ) : string Get QR-Code URL for image, from google charts.
setCodeLength ( integer $length ) : PHPGangsta_GoogleAuthenticator Set the code length, should be >=6.
verifyCode ( string $secret, string $code, integer $discrepancy = 1, integer | null $currentTimeSlice = null ) : boolean Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now.

Защищенные методы

Метод Описание
_base32Decode ( $secret ) : boolean | string Helper class to decode base32.
_getBase32LookupTable ( ) : array Get array with all 32 characters for decoding from/encoding to base32.

Приватные методы

Метод Описание
timingSafeEquals ( string $safeString, string $userString ) : boolean A timing safe equals comparison more info here: http://blog.ircmaxell.com/2014/11/its-all-about-time.html.

Описание методов

_base32Decode() защищенный Метод

Helper class to decode base32.
protected _base32Decode ( $secret ) : boolean | string
$secret
Результат boolean | string

_getBase32LookupTable() защищенный Метод

Get array with all 32 characters for decoding from/encoding to base32.
protected _getBase32LookupTable ( ) : array
Результат array

createSecret() публичный Метод

16 characters, randomly chosen from the allowed base32 characters.
public createSecret ( integer $secretLength = 16 ) : string
$secretLength integer
Результат string

getCode() публичный Метод

Calculate the code, with given secret and point in time.
public getCode ( string $secret, integer | null $timeSlice = null ) : string
$secret string
$timeSlice integer | null
Результат string

getQRCodeGoogleUrl() публичный Метод

Get QR-Code URL for image, from google charts.
public getQRCodeGoogleUrl ( string $name, string $secret, string $title = null, array $params = [] ) : string
$name string
$secret string
$title string
$params array
Результат string

setCodeLength() публичный Метод

Set the code length, should be >=6.
public setCodeLength ( integer $length ) : PHPGangsta_GoogleAuthenticator
$length integer
Результат PHPGangsta_GoogleAuthenticator

verifyCode() публичный Метод

Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now.
public verifyCode ( string $secret, string $code, integer $discrepancy = 1, integer | null $currentTimeSlice = null ) : boolean
$secret string
$code string
$discrepancy integer This is the allowed time drift in 30 second units (8 means 4 minutes before or after)
$currentTimeSlice integer | null time slice if we want use other that time()
Результат boolean

Описание свойств

$_codeLength защищенное свойство

protected $_codeLength