コード例 #1
0
ファイル: test_libthumbor.py プロジェクト: APSL/libthumbor
def test_thumbor_can_decrypt_lib_thumbor_generated_url():
    key = "my-security-key"
    image = "s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg"
    thumbor_crypto = Cryptor(key)

    crypto = CryptoURL(key=key)

    url = crypto.generate(
        width=300,
        height=200,
        smart=True,
        image_url=image,
        old=True
    )

    reg = "/([^/]+)/(.+)"
    options = re.match(reg, url).groups()[0]

    decrypted_url = thumbor_crypto.decrypt(options)

    assert decrypted_url
    assert decrypted_url['height'] == 200
    assert decrypted_url['width'] == 300
    assert decrypted_url['smart']
    assert decrypted_url['image_hash'] == hashlib.md5(b(image)).hexdigest()
コード例 #2
0
ファイル: test_libthumbor.py プロジェクト: APSL/libthumbor
def test_usage():
    key = "my-security-key"
    image = "s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg"
    thumbor_crypto = Cryptor(key)

    thumbor_options = thumbor_crypto.encrypt(
        width=300,
        height=200,
        smart=True,
        adaptive=False,
        full=False,
        fit_in=False,
        flip_horizontal=False,
        flip_vertical=False,
        halign='center',
        valign='middle',
        trim=None,
        crop_left=0,
        crop_top=0,
        crop_right=0,
        crop_bottom=0,
        filters=[],
        image=image
    )

    if PY3:
        thumbor_options = thumbor_options.decode('ascii')
    thumbor_url = "/%s/%s" % (thumbor_options, image)

    crypto = CryptoURL(key=key)

    url = crypto.generate(
        width=300,
        height=200,
        smart=True,
        image_url=image,
        old=True
    )

    assert url == thumbor_url
コード例 #3
0
def test_thumbor_can_decrypt_lib_thumbor_generated_url():
    key = "my-security-key"
    image = "s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg"
    thumbor_crypto = Cryptor(key)

    crypto = CryptoURL(key=key)

    url = crypto.generate(width=300,
                          height=200,
                          smart=True,
                          image_url=image,
                          old=True)

    reg = "/([^/]+)/(.+)"
    options = re.match(reg, url).groups()[0]

    decrypted_url = thumbor_crypto.decrypt(options)

    assert decrypted_url
    assert decrypted_url['height'] == 200
    assert decrypted_url['width'] == 300
    assert decrypted_url['smart']
    assert decrypted_url['image_hash'] == hashlib.md5(b(image)).hexdigest()
コード例 #4
0
def test_usage():
    key = "my-security-key"
    image = "s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg"
    thumbor_crypto = Cryptor(key)

    thumbor_options = thumbor_crypto.encrypt(width=300,
                                             height=200,
                                             smart=True,
                                             adaptive=False,
                                             full=False,
                                             fit_in=False,
                                             flip_horizontal=False,
                                             flip_vertical=False,
                                             halign='center',
                                             valign='middle',
                                             trim=None,
                                             crop_left=0,
                                             crop_top=0,
                                             crop_right=0,
                                             crop_bottom=0,
                                             filters=[],
                                             image=image)

    if PY3:
        thumbor_options = thumbor_options.decode('ascii')
    thumbor_url = "/%s/%s" % (thumbor_options, image)

    crypto = CryptoURL(key=key)

    url = crypto.generate(width=300,
                          height=200,
                          smart=True,
                          image_url=image,
                          old=True)

    assert url == thumbor_url
コード例 #5
0
def decrypt_in_thumbor(key, encrypted):
    '''Uses thumbor to decrypt libthumbor's encrypted URL'''
    crypto = Cryptor(key)
    return crypto.decrypt(encrypted)
コード例 #6
0
ファイル: test_url_composer.py プロジェクト: APSL/libthumbor
def decrypt_in_thumbor(key, encrypted):
    '''Uses thumbor to decrypt libthumbor's encrypted URL'''
    crypto = Cryptor(key)
    return crypto.decrypt(encrypted)
コード例 #7
0
ファイル: test_cryptourl.py プロジェクト: APSL/libthumbor
def decrypt_in_thumbor(url):
    '''Uses thumbor to decrypt libthumbor's encrypted URL'''
    encrypted = url.split('/')[1]
    cryptor = Cryptor(KEY)
    return cryptor.decrypt(encrypted)