Methods summary
public
|
#
__construct( string $initKey = null )
Initialize the object and set up the lookup table
Optionally the Initialization key
Initialize the object and set up the lookup table Optionally the Initialization key
Parameters
- $initKey
- Initialization key
|
public
|
#
buildLookup( )
Build the base32 lookup table
Build the base32 lookup table
|
public
integer
|
#
getRange( )
Get the current "range" value
Get the current "range" value
Returns
integer Range value
|
public
TOTP\Auth
|
#
setRange( integer $range )
Set the "range" value
Parameters
Returns
|
public
TOTP\Auth
|
#
setInitKey( string $key )
Set the initialization key for the object
Set the initialization key for the object
Parameters
Returns
Throws
InvalidArgumentException If hash is not valid base32
|
public
string
|
#
getInitKey( )
Get the current Initialization key
Get the current Initialization key
Returns
string Initialization key
|
public
TOTP\Auth
|
#
setLookup( array $lookup )
Set the contents of the internal lookup table
Set the contents of the internal lookup table
Parameters
Returns
Throws
InvalidArgumentException If lookup given is not an array
|
public
array
|
#
getLookup( )
Get the current lookup data set
Get the current lookup data set
Returns
array Lookup data
|
public
integer
|
#
getRefresh( )
Get the number of seconds for code refresh currently set
Get the number of seconds for code refresh currently set
Returns
integer Refresh in seconds
|
public
TOTP\Auth
|
#
setRefresh( integer $seconds )
Set the number of seconds to refresh codes
Set the number of seconds to refresh codes
Parameters
- $seconds
- Seconds to refresh
Returns
Throws
InvalidArgumentException If seconds value is not numeric
|
public
integer
|
#
getCodeLength( )
Get the current length for generated codes
Get the current length for generated codes
Returns
integer Code length
|
public
TOTP\Auth
|
#
setCodeLength( integer $length )
Set the length of the generated codes
Set the length of the generated codes
Parameters
Returns
|
public
boolean
|
#
validateCode( string $code, string $initKey = null, string $timestamp = null, integer $range = null )
Validate the given code
Parameters
- $code
- Code entered by user
- $initKey
- Initialization key
- $timestamp
- Timestamp for calculation
- $range
- Seconds before/after to validate hash against
Returns
boolean Pass/fail of validation
Throws
InvalidArgumentException If incorrect code length
|
public
string
|
#
generateOneTime( string $initKey = null, string $timestamp = null )
Generate a one-time code
Parameters
- $initKey
- Initialization key [optional]
- $timestamp
- Timestamp for calculation [optional]
Returns
string Generated code/hash
|
public
string
|
#
generateCode( integer $length = 16 )
Generate a code/hash
Useful for making Initialization codes
Generate a code/hash Useful for making Initialization codes
Parameters
- $length
- Length for the generated code
Returns
string Generated code
|
public
integer
|
#
generateTimestamp( )
Generate the timestamp for the calculation
Generate the timestamp for the calculation
Returns
integer Timestamp
|
public
string
|
#
truncateHash( string $hash )
Truncate the given hash down to just what we need
Truncate the given hash down to just what we need
Parameters
Returns
string Truncated hash value
|
public
string
|
#
base32_decode( string $hash )
Base32 decoding function
Parameters
- $hash
- The base32-encoded hash
Returns
string Binary value of hash
Throws
InvalidArgumentException When hash is not valid
|
public
string
|
#
getQrCodeUrl( string $name, string $code )
Returns a URL to QR code for embedding the QR code
Returns a URL to QR code for embedding the QR code
Parameters
- $name
- The name
- $code
- The generated code
Returns
string The URL to the QR code
|