PHP Class Google2FA, TeamPass

More licences we sell, more products we develop in the future.
显示文件 Open project: nilsteampassnet/TeamPass Class Usage Examples

Public Methods

Method Description
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.

Method Details

base32_decode() public method

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

generate_secret_key() public method

Generates a 16 digit secret key in base32 format
public generate_secret_key ( $length = 16 ) : string
return string

get_qr_code() public method

public get_qr_code ( $username, $secret )

get_qr_code_url() public method

public get_qr_code_url ( $username, $secret )

get_timestamp() public method

Returns the current Unix Timestamp devided by the KEYREGENERATION period.
public get_timestamp ( ) : integer
return integer

oath_hotp() public method

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.
return string

oath_truncate() public method

Extracts the OTP from the SHA1 hash.
public oath_truncate ( binary $hash ) : integer
$hash binary
return integer

verify_key() public method

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
return boolean