\PHPGangsta_GoogleAuthenticator

PHP Class for handling Google Authenticator 2-factor authentication

Summary

Methods
Properties
Constants
createSecret()
getCode()
getQRCodeGoogleUrl()
verifyCode()
setCodeLength()
No public properties found
No constants found
_base32Decode()
_base32Encode()
_getBase32LookupTable()
$_codeLength
N/A
No private methods found
No private properties found
N/A

Properties

$_codeLength

$_codeLength : 

Type

Methods

createSecret()

createSecret(integer  $secretLength = 16) : string

Create new secret.

16 characters, randomly chosen from the allowed base32 characters.

Parameters

integer $secretLength

Returns

string

getCode()

getCode(string  $secret, integer|null  $timeSlice = null) : string

Calculate the code, with given secret and point in time

Parameters

string $secret
integer|null $timeSlice

Returns

string

getQRCodeGoogleUrl()

getQRCodeGoogleUrl(string  $name, string  $secret) : string

Get QR-Code URL for image, from google charts

Parameters

string $name
string $secret

Returns

string

verifyCode()

verifyCode(string  $secret, string  $code, integer  $discrepancy = 1) : boolean

Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now

Parameters

string $secret
string $code
integer $discrepancy

This is the allowed time drift in 30 second units (8 means 4 minutes before or after)

Returns

boolean

setCodeLength()

setCodeLength(integer  $length) : \PHPGangsta_GoogleAuthenticator

Set the code length, should be >=6

Parameters

integer $length

Returns

\PHPGangsta_GoogleAuthenticator

_base32Decode()

_base32Decode(  $secret) : boolean|string

Helper class to decode base32

Parameters

$secret

Returns

boolean|string

_base32Encode()

_base32Encode(string  $secret, boolean  $padding = true) : string

Helper class to encode base32

Parameters

string $secret
boolean $padding

Returns

string

_getBase32LookupTable()

_getBase32LookupTable() : array

Get array with all 32 characters for decoding from/encoding to base32

Returns

array