SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class GoogleAuthenticator

Variables

NameVisibilityDescription
$PASS_CODE_LENGTH (static) 
$SECRET_LENGTH (static) 

Functions

NameVisibilityDescription
checkCodepublicCheck a given code against a given secret
generateSecretpublicGenerate a secret key and encode as base32
getCodeprotectedCalculate what the code for a given secret/time should be
getQRDatapublicFor a given set of details, return the otpauth:// url for use in a QR code
getQRImageUrlpublicReturn a Google Charts url which generates a QR code image from some QR code data

public checkCode

bool $GoogleAuthenticator->checkCode ( string $secret , string $code );

Check a given code against a given secret

Does the check three times, for current time, one period before, and one period after
This is to allow for clock drift

public generateSecret

string $GoogleAuthenticator->generateSecret ( );

Generate a secret key and encode as base32

NOTE: Only cryptographically secure in PHP 7.0 onwards (uses "random_bytes" method)
On earlier versions of PHP this method isn't available so rand() is used instead

protected getCode

string $GoogleAuthenticator->getCode ( string $secret , int $time );

Calculate what the code for a given secret/time should be

public getQRData

string $GoogleAuthenticator->getQRData ( string $issuer , string $user , string $host , string $secret );

For a given set of details, return the otpauth:// url for use in a QR code

public getQRImageUrl

string $GoogleAuthenticator->getQRImageUrl ( string $qr_data );

Return a Google Charts url which generates a QR code image from some QR code data