You are here

function ga_login_test_generate_code in Google Authenticator login 7

Generate the code for a given secret.

@returns int Returns 6 digit code.

Parameters

string $secret: Secret as generated by the ga4php class.

int $timestamp_offset: Timestamp offset.

5 calls to ga_login_test_generate_code()
GaLoginBasicPermissionsTestCase::testCheckboxOnAccountEditPage in ./ga_login.test
Test checkbox on account edit page and delete code operation.
GaLoginBasicPermissionsTestCase::testCreateOwnLoginCodeOncePermission in ./ga_login.test
Test create own login code once.
GaLoginBasicPermissionsTestCase::testCreateOwnLoginCodePermission in ./ga_login.test
Test create own login code.
GaLoginOthersPermissionsTestCase::testCheckboxOnAccountEditPage in ./ga_login.test
Test checkbox on account edit page.
GaLoginOthersPermissionsTestCase::testCreateOthersLoginCodesPermission in ./ga_login.test
Test create others login codes.

File

tests/ga_login_test/ga_login_test.module, line 31
ga_login_test module.

Code

function ga_login_test_generate_code($secret, $timestamp_offset = 0) {
  $timestamp = Google2FA::getTimestamp();
  $timestamp += $timestamp_offset;
  $secretkey = Google2FA::base32Decode($secret);
  return Google2FA::oathHotp($secretkey, $timestamp);
}