|
31 | 31 | DISPLAY_RATE = 1 # screen refresh rate |
32 | 32 | #------------------------------------------------------------------------- |
33 | 33 |
|
34 | | -# Get secrets from a secrets.py file |
| 34 | +# Get totp_keys from a totp_keys.py file |
35 | 35 | try: |
36 | | - from secrets import secrets |
37 | | - totp_keys = secrets["totp_keys"] |
| 36 | + from totp_keys import totp_keys |
38 | 37 | except ImportError: |
39 | | - print("Secrets are kept in secrets.py, please add them there!") |
40 | | - raise |
41 | | -except KeyError: |
42 | | - print("TOTP info not found in secrets.py.") |
| 38 | + print("TOTP info not found in totp_keys.py, please add them there!") |
43 | 39 | raise |
44 | 40 |
|
45 | 41 | # set board to use PCF8523 as its RTC |
|
80 | 76 | rtc_time.anchor_point = (0.0, 0.5) |
81 | 77 | rtc_time.anchored_position = (0, 59) |
82 | 78 |
|
83 | | -progress_bar = HorizontalProgressBar((68, 46), (55, 17), bar_color=0xFFFFFF, min_value=0, max_value=30) |
| 79 | +progress_bar = HorizontalProgressBar( |
| 80 | + (68, 46), (55, 17), bar_color=0xFFFFFF, min_value=0, max_value=30 |
| 81 | +) |
84 | 82 |
|
85 | 83 | splash = displayio.Group() |
86 | 84 | splash.append(name) |
@@ -172,15 +170,15 @@ def generate_otp(int_input, secret_key, digits=6): |
172 | 170 | int_to_bytestring(int_input)).digest() |
173 | 171 | ) |
174 | 172 | offset = hmac_hash[-1] & 0xf |
175 | | - code = ((hmac_hash[offset] & 0x7f) << 24 | |
176 | | - (hmac_hash[offset + 1] & 0xff) << 16 | |
177 | | - (hmac_hash[offset + 2] & 0xff) << 8 | |
178 | | - (hmac_hash[offset + 3] & 0xff)) |
179 | | - str_code = str(code % 10 ** digits) |
180 | | - while len(str_code) < digits: |
181 | | - str_code = '0' + str_code |
| 173 | + otp_code = ((hmac_hash[offset] & 0x7f) << 24 | |
| 174 | + (hmac_hash[offset + 1] & 0xff) << 16 | |
| 175 | + (hmac_hash[offset + 2] & 0xff) << 8 | |
| 176 | + (hmac_hash[offset + 3] & 0xff)) |
| 177 | + str_otp_code = str(otp_code % 10 ** digits) |
| 178 | + while len(str_otp_code) < digits: |
| 179 | + str_otp_code = '0' + str_otp_code |
182 | 180 |
|
183 | | - return str_code |
| 181 | + return str_otp_code |
184 | 182 |
|
185 | 183 | #------------------------------------------------------------------------- |
186 | 184 | # M A C R O P A D S E T U P |
|
0 commit comments