PHP Класс Google2FA, TeamPass

More licences we sell, more products we develop in the future.
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
base32_decode ( $b32 ) Decodes a base32 string into a binary string.
generate_secret_key ( $length = 16 ) : string Generates a 16 digit secret key in base32 format
get_qr_code ( $username, $secret )
get_qr_code_url ( $username, $secret )
get_timestamp ( ) : integer Returns the current Unix Timestamp devided by the KEYREGENERATION period.
oath_hotp ( binary $key, integer $counter ) : string Takes the secret key and the timestamp and returns the one time password.
oath_truncate ( binary $hash ) : integer Extracts the OTP from the SHA1 hash.
verify_key ( string $b32seed, string $key, integer $window = 4, boolean $useTimeStamp = true ) : boolean Verifys a user inputted key against the current timestamp. Checks $window keys either side of the timestamp.

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

base32_decode() публичный метод

Decodes a base32 string into a binary string.
public base32_decode ( $b32 )

generate_secret_key() публичный метод

Generates a 16 digit secret key in base32 format
public generate_secret_key ( $length = 16 ) : string
Результат string

get_qr_code() публичный метод

public get_qr_code ( $username, $secret )

get_qr_code_url() публичный метод

public get_qr_code_url ( $username, $secret )

get_timestamp() публичный метод

Returns the current Unix Timestamp devided by the KEYREGENERATION period.
public get_timestamp ( ) : integer
Результат integer

oath_hotp() публичный метод

Takes the secret key and the timestamp and returns the one time password.
public oath_hotp ( binary $key, integer $counter ) : string
$key binary - Secret key in binary form.
$counter integer - Timestamp as returned by get_timestamp.
Результат string

oath_truncate() публичный метод

Extracts the OTP from the SHA1 hash.
public oath_truncate ( binary $hash ) : integer
$hash binary
Результат integer

verify_key() публичный метод

Verifys a user inputted key against the current timestamp. Checks $window keys either side of the timestamp.
public verify_key ( string $b32seed, string $key, integer $window = 4, boolean $useTimeStamp = true ) : boolean
$b32seed string
$key string - User specified key
$window integer
$useTimeStamp boolean
Результат boolean