def generate_new(self, options): url = plain_image_url(**options) _hmac = self.hmac.copy() _hmac.update(text_type(url).encode("utf-8")) signature = base64.urlsafe_b64encode(_hmac.digest()).decode("ascii") return f"/{signature}/{url}"
def generate_new(self, options): url = plain_image_url(**options) signature = base64.urlsafe_b64encode(hmac.new(b(self.key), text_type(url).encode('utf-8'), hashlib.sha1).digest()) if PY3: signature = signature.decode('ascii') return '/%s/%s' % (signature, url)
def generate_new(self, options): url = plain_image_url(**options) signature = base64.urlsafe_b64encode( hmac.new(self.key, unicode(url).encode('utf-8'), hashlib.sha1).digest()) return '/%s/%s' % (signature, url)
def generate_new(self, options): url = plain_image_url(**options) _hmac = self.hmac.copy() _hmac.update(text_type(url).encode('utf-8')) signature = base64.urlsafe_b64encode(_hmac.digest()) if PY3: signature = signature.decode('ascii') return '/%s/%s' % (signature, url)
def generate(self, **options): import urllib url = plain_image_url(**options) url = urllib.quote(url.encode('utf-8'), '/:?%=&()~",\'') signature = base64.urlsafe_b64encode( hmac.new(self.key, unicode(url).encode('utf-8'), hashlib.sha1).digest()) pad = lambda s: s + (32 - len(s) % 32) * "$" cypher = AES.new((self.key * 32)[:32]) encrypted = base64.urlsafe_b64encode( cypher.encrypt(pad(url.encode('utf-8')))) return '/%s/%s.jpg' % (signature, encrypted)
def generate_new(self, options): url = plain_image_url(**options) signature = base64.urlsafe_b64encode(hmac.new(self.key, unicode(url).encode('utf-8'), hashlib.sha1).digest()) return '/%s/%s' % (signature, url)
def generate_new(self, options): url = plain_image_url(**options) signature = base64.urlsafe_b64encode(hmac.new(self.key, bytes(url, encoding='ascii'), hashlib.sha1).digest()) return '/%s/%s' % (str(signature, encoding='utf-8'), url)