Replace Function key32gen() with generateTotpSecret()

This commit is contained in:
johnnyq
2026-07-14 17:27:02 -04:00
parent b57ddc0e5c
commit 8de3cd300d
3 changed files with 4 additions and 4 deletions

View File

@@ -12,7 +12,7 @@ $company_logo = escapeHtml($row['company_logo']);
// Only generate the token once and store it in session:
if (empty($_SESSION['mfa_token'])) {
$token = key32gen();
$token = generateTotpSecret();
$_SESSION['mfa_token'] = $token;
}
$token = $_SESSION['mfa_token'];

View File

@@ -3,7 +3,7 @@ require_once '../../libs/totp/totp.php';
// Only generate the token once and store it in session:
if (empty($_SESSION['mfa_token'])) {
$token = key32gen();
$token = generateTotpSecret();
$_SESSION['mfa_token'] = $token;
}
$token = $_SESSION['mfa_token'];

View File

@@ -14,8 +14,8 @@ function randomString(int $length = 16): string {
);
}
// Used only for TOTP
function key32gen() {
// Generate a cryptographically secure 32-char base32 secret for TOTP
function generateTotpSecret() {
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
$key = '';
for ($i = 0; $i < 32; $i++) {