mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-10 16:24:49 +00:00
Make generate_signature Python 3 compatible
This commit is contained in:
parent
a7610ec7be
commit
a580f7d286
1 changed files with 4 additions and 2 deletions
|
|
@ -5,6 +5,8 @@ import base64
|
|||
import hmac
|
||||
import hashlib
|
||||
|
||||
from six import b
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
|
|
@ -78,8 +80,8 @@ def parse_filter_spec(filter_spec):
|
|||
def generate_signature(image_id, filter_spec):
|
||||
# Based on libthumbor hmac generation
|
||||
# https://github.com/thumbor/libthumbor/blob/b19dc58cf84787e08c8e397ab322e86268bb4345/libthumbor/crypto.py#L50
|
||||
url = str(image_id) + '/' + filter_spec + '/'
|
||||
return base64.urlsafe_b64encode(hmac.new(settings.SECRET_KEY, url, hashlib.sha1).digest())
|
||||
url = str(image_id) + '/' + str(filter_spec) + '/'
|
||||
return base64.urlsafe_b64encode(hmac.new(b(settings.SECRET_KEY), b(url), hashlib.sha1).digest())
|
||||
|
||||
|
||||
def verify_signature(signature, image_id, filter_spec):
|
||||
|
|
|
|||
Loading…
Reference in a new issue