Overview

Namespaces

  • MatthiasMullie
    • Minify
      • Exceptions
    • PathConverter
  • None
  • ReCaptcha
    • RequestMethod
  • TOTP

Classes

  • Auth
  • Overview
  • Namespace
  • Class

Class Auth

Class Auth

Namespace: TOTP
Package: TOTP
Located at Sources/Class-TOTP.php
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

Set the "range" value

Parameters

$range
Range value

Returns

TOTP\Auth
instance
public TOTP\Auth
# setInitKey( string $key )

Set the initialization key for the object

Set the initialization key for the object

Parameters

$key
Initialization key

Returns

TOTP\Auth
instance

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

$lookup
Lookup data set

Returns

TOTP\Auth
instance

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

TOTP\Auth
instance

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

$length
Code length

Returns

TOTP\Auth
instance
public boolean
# validateCode( string $code, string $initKey = null, string $timestamp = null, integer $range = null )

Validate the given code

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

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

$hash
Hash to truncate

Returns

string
Truncated hash value
public string
# base32_decode( string $hash )

Base32 decoding function

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
API documentation generated by ApiGen