Skip to content

Commit 9d0fd1f

Browse files
author
brentru
committed
add totp_keys as an entry to secrets.py instead of placing secrets in user-code
1 parent b021901 commit 9d0fd1f

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

PyPortal_TOTP_Friend/code.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
print("WiFi secrets are kept in secrets.py, please add them there!")
1515
raise
1616

17-
# https://github.com/pyotp/pyotp example
18-
totp = [("Gmail ", 'JBSWY3DPEHPK3PXP')]
19-
2017

2118
TEST = True # if you want to print out the tests the hashers
2219
ALWAYS_ON = False # Set to true if you never want to go to sleep!
@@ -167,9 +164,8 @@ def generate_otp(int_input, secret_key, digits=6):
167164
while ALWAYS_ON or (countdown > 0):
168165
# Calculate current time based on NTP + monotonic
169166
unix_time = t - mono_time + int(time.monotonic())
170-
print("Unix time: ", unix_time)
171-
# We can do up to 3 per line on the Feather OLED
172-
for name, secret in totp:
167+
# print("Unix time: ", unix_time)
168+
for name, secret in secrets['totp_keys']:
173169
otp = generate_otp(unix_time // 30, secret)
174170
print(name + " OTP output: ", otp) # serial debugging output
175171
# We'll update every 1/4 second, we can hash very fast so its no biggie!

PyPortal_TOTP_Friend/secrets2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file is where you keep secret settings, passwords, and tokens!
2+
# If you put them in the code you risk committing that info or sharing it
3+
4+
secrets = {
5+
'ssid' : 'yourwifissid',
6+
'password' : 'yourwifipassword',
7+
'timezone' : "America/New_York", # http://worldtimeapi.org/timezones
8+
# https://github.com/pyotp/pyotp example
9+
'totp_keys' : [("Gmail ", "JBSWY3DPEHPK3PXP")]
10+
}

0 commit comments

Comments
 (0)