You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm very new to the Raspberry Pi ecosystem. I've been trying to make a Raspberry Pi Pico totp generator and have gotten to the point of displaying a totp code. Since totp is built around SHA1 by default I've been trying to do the following to no avail. I'm using Thonny as the IDE of choice to work in and have installed the micropython-hashlib v0.0.1 latest stable.
import time
import ubinascii
import uhashlib
import lcd
from machine import Pin
I've also tried switching uhaslib to hashlib but still no dice. When exploring the package it has _sha224.py, _sha256.py, etc but no _sha1.py and init.py shows sha1 in the def init()
Hi,
I'm very new to the Raspberry Pi ecosystem. I've been trying to make a Raspberry Pi Pico totp generator and have gotten to the point of displaying a totp code. Since totp is built around SHA1 by default I've been trying to do the following to no avail. I'm using Thonny as the IDE of choice to work in and have installed the micropython-hashlib v0.0.1 latest stable.
import time
import ubinascii
import uhashlib
import lcd
from machine import Pin
totp = [("Discord ", 'JBSWY3DPEHPK3PXP')]
TEST = True
ALWAYS_ON = True
ON_SECONDS = 10
EPOCH_DELTA = 1638239843
SECS_DAY = 86400
SHA1 = uhashlib.sha1
LCD = lcd.LCD_1inch14()
def HMAC(k, m):
SHA1_BLOCK_SIZE = 64
KEY_BLOCK = k + (b'\0' * (SHA1_BLOCK_SIZE - len(k)))
KEY_INNER = bytes((x ^ 0x36) for x in KEY_BLOCK)
KEY_OUTER = bytes((x ^ 0x5C) for x in KEY_BLOCK)
inner_message = KEY_INNER + m
outer_message = KEY_OUTER + SHA1(inner_message).digest()
return SHA1(outer_message)
I get the following message: AttributeError: 'module' object has no attribute 'sha1'
The text was updated successfully, but these errors were encountered: