function tfa_generate_code in Two-factor Authentication (TFA) 7
Same name and namespace in other branches
- 6 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_resend_code in ./
tfa.pages.inc - Resend code.
- tfa_user_login in ./
tfa.module - Implements hook_user_login().
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;
}