From e8d655a7b22fb99f05aa373a122cd582044d6a76 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Tue, 10 Jan 2023 13:19:22 -0600 Subject: [PATCH] it works! --- src/main.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 891f22e..bc16289 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,9 @@ -// The codes that are displayed are not consistent with the GOOGLE Authenticator -// app.... I guess that TOTP library has an issue... +// to get the code from Google Authenticator you need to decode base32 and +// convert that to hex: +/* +echo -n "F4ZVI6KKNF4SW5DG" |base32 -d | xxd -ps +2f3354794a69792b7466 +*/ // I connected SCL to D22 and SDA to D21 @@ -23,10 +27,10 @@ WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP); -uint8_t hmacKey[] = {0x62, 0x27, 0x2F, 0x33, 0x54, 0x79, 0x4A, - 0x69, 0x79, 0x2B, 0x74, 0x66, 0x27}; +uint8_t hmacKey[] = {0x2F, 0x33, 0x54, 0x79, 0x4A, + 0x69, 0x79, 0x2B, 0x74, 0x66}; -TOTP totp = TOTP(hmacKey, 12); +TOTP totp = TOTP(hmacKey, 10); char code[7]; unsigned long lastMsg = 0;