mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-30 03:50:40 +00:00
parent
c5a215b11d
commit
f9d8115ba6
2 changed files with 3 additions and 3 deletions
|
@ -61,7 +61,7 @@ def broadcast_task(sender_id, activity, recipients):
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
|
||||||
def sign_and_send(sender, activity, destination):
|
def sign_and_send(sender, data, destination):
|
||||||
''' crpyto whatever and http junk '''
|
''' crpyto whatever and http junk '''
|
||||||
now = http_date()
|
now = http_date()
|
||||||
|
|
||||||
|
@ -69,7 +69,6 @@ def sign_and_send(sender, activity, destination):
|
||||||
# this shouldn't happen. it would be bad if it happened.
|
# this shouldn't happen. it would be bad if it happened.
|
||||||
raise ValueError('No private key found for sender')
|
raise ValueError('No private key found for sender')
|
||||||
|
|
||||||
data = json.dumps(activity).encode('utf-8')
|
|
||||||
digest = make_digest(data)
|
digest = make_digest(data)
|
||||||
|
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
|
|
|
@ -44,7 +44,8 @@ def make_signature(sender, destination, date, digest):
|
||||||
|
|
||||||
def make_digest(data):
|
def make_digest(data):
|
||||||
''' creates a message digest for signing '''
|
''' creates a message digest for signing '''
|
||||||
return 'SHA-256=' + b64encode(hashlib.sha256(data).digest()).decode('utf-8')
|
return 'SHA-256=' + b64encode(hashlib.sha256(data.encode('utf-8'))\
|
||||||
|
.digest()).decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
def verify_digest(request):
|
def verify_digest(request):
|
||||||
|
|
Loading…
Reference in a new issue