diff options
author | Philipp Hörist <forenjunkie@chello.at> | 2017-08-07 21:47:50 +0300 |
---|---|---|
committer | Philipp Hörist <forenjunkie@chello.at> | 2017-08-07 21:50:02 +0300 |
commit | e06b95c06b6aa5ef7ef7e62b90e64185d922a633 (patch) | |
tree | 96b9640bc96760fb402b40c20cc6e6df77aa1b8f | |
parent | 4dac406cdf87ec6a1796bc5ab3c2410dbe51ce7b (diff) |
[url_image_preview] Support 12bit IVs
Support 12bit IVs on encrypted httpupload files
-rw-r--r-- | url_image_preview/url_image_preview.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/url_image_preview/url_image_preview.py b/url_image_preview/url_image_preview.py index d62e208..36e9e8a 100644 --- a/url_image_preview/url_image_preview.py +++ b/url_image_preview/url_image_preview.py @@ -19,6 +19,7 @@ import gtk import gobject import os import hashlib +import binascii from urlparse import urlparse from io import BytesIO import shutil @@ -198,18 +199,17 @@ class Base(object): key = '' iv = '' encrypted = False - if len(urlparts.fragment): - fragment = [] - try: - for i in range(0, len(urlparts.fragment), 2): - fragment.append(chr(int(urlparts.fragment[i:i + 2], 16))) - fragment = ''.join(fragment) - key = fragment[16:] - iv = fragment[:16] - if len(key) == 32 and len(iv) == 16: + if urlparts.fragment: + fragment = binascii.unhexlify(urlparts.fragment) + key = fragment[16:] + iv = fragment[:16] + if len(key) == 32 and len(iv) == 16: + encrypted = True + if not encrypted: + key = fragment[12:] + iv = fragment[:12] + if len(key) == 32 and len(iv) == 12: encrypted = True - except: - pass # file exists but thumbnail got deleted if os.path.exists(filepath) and not os.path.exists(thumbpath): |