mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-29 13:30:26 -07:00
Actually, the secret is ASCII bytes
It looks like hex, but really it's just ASCII. Wow!
This commit is contained in:
parent
3b5b6ca07f
commit
8653810e0d
5
wideq.py
5
wideq.py
@ -30,10 +30,11 @@ def oauth2_signature(message, secret):
|
|||||||
"""Get the base64-encoded SHA-1 HMAC digest of a string, as used in
|
"""Get the base64-encoded SHA-1 HMAC digest of a string, as used in
|
||||||
OAauth2 request signatures.
|
OAauth2 request signatures.
|
||||||
|
|
||||||
The `secret` is provided as a base64-encoded string.
|
Both the `secret` and `message` are given as text strings. We use
|
||||||
|
their UTF-8 equivalents.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
secret_bytes = base64.b64decode(secret)
|
secret_bytes = secret.encode('utf8')
|
||||||
hashed = hmac.new(secret_bytes, message.encode('utf8'), hashlib.sha1)
|
hashed = hmac.new(secret_bytes, message.encode('utf8'), hashlib.sha1)
|
||||||
digest = hashed.digest()
|
digest = hashed.digest()
|
||||||
return base64.b64encode(digest)
|
return base64.b64encode(digest)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user