You are here

function tfa_generate_code in Two-factor Authentication (TFA) 6

Same name and namespace in other branches
  1. 7 tfa.module \tfa_generate_code()

Generate the code for TFA.

Parameters

object $account User account.:

Return value

string Random code or "nonce".

2 calls to tfa_generate_code()
tfa_code_form_validate in ./tfa.pages.inc
Validate handler for TFA login form.
tfa_user in ./tfa.module
Implements hook_user().

File

./tfa.module, line 214
Two-factor authentication for Drupal.

Code

function tfa_generate_code($account) {
  $code_length = variable_get('tfa_code_length', 6);

  // Generate a randomized string of characters.
  $code = substr(str_shuffle(str_repeat("123456789abcdefghjkmnpqrstuvwxyz", 5)), 0, $code_length);
  return $code;
}