Even more code cleanup

This commit is contained in:
Anthony Wang 2023-01-18 20:07:12 +00:00
parent 315b1c635c
commit a56c2664dc
No known key found for this signature in database
GPG key ID: 42A5B952E6DD8D38

View file

@ -12,12 +12,12 @@ date = formatdate(usegmt=True)
digester = hashes.Hash(hashes.SHA256())
digester.update(activity)
digest = b64encode(digester.finalize()).decode()
message = f'date: {date}\ndigest: SHA-256={digest}'
message = f'date: {date}\ndigest: SHA-256={digest}'.encode('utf8')
with open('private.pem', 'rb') as f:
privkey = serialization.load_pem_private_key(f.read(), None)
signature = b64encode(privkey.sign(message.encode('utf8'), padding.PKCS1v15(), hashes.SHA256())).decode()
signature = b64encode(privkey.sign(message, padding.PKCS1v15(), hashes.SHA256())).decode()
header = f'keyId="https://0.exozy.me/users/test.jsonld#main-key",headers="date digest",signature="{signature}"'
resp = post('https://0.exozy.me/users/test.outbox', headers={