I need to compute the hash string that will match any future hash “within the past hour” starting from now.
I mistakenly did:
now = datetime.now()
hash = now.strftime("%D %H")
but that simply truncates the minutes so if I am at say 4:55, within 5 minutes the “hour” is up.
The past hour is necessary to be part of the hashing since the consumer of the hash string needs to know if the hash was computed within the past hour.
The simple, approximate solution, similar to mgibsonbr’s suggestion, would be to generate a new token with the current hour and then if that fails, check again with the past hour.