aboutsummaryrefslogtreecommitdiff
path: root/pandora/transport.py
diff options
context:
space:
mode:
Diffstat (limited to 'pandora/transport.py')
-rw-r--r--pandora/transport.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pandora/transport.py b/pandora/transport.py
index aeba50d..f609cee 100644
--- a/pandora/transport.py
+++ b/pandora/transport.py
@@ -313,6 +313,14 @@ class PurePythonBlowfish(BlowfishCryptor):
313 return b"".join(self.cipher.encrypt_ecb(self._add_padding(data))) 313 return b"".join(self.cipher.encrypt_ecb(self._add_padding(data)))
314 314
315 315
316# Python 3 users can use pure-python mode, if possible prefer that as default
317try:
318 import blowfish
319 default_crypto_class = PurePythonBlowfish
320except ImportError:
321 default_crypto_class = CryptographyBlowfish
322
323
316class Encryptor(object): 324class Encryptor(object):
317 """Pandora Blowfish Encryptor 325 """Pandora Blowfish Encryptor
318 326
@@ -320,7 +328,7 @@ class Encryptor(object):
320 API request and response. It handles the formats that the API expects. 328 API request and response. It handles the formats that the API expects.
321 """ 329 """
322 330
323 def __init__(self, in_key, out_key, crypto_class=CryptographyBlowfish): 331 def __init__(self, in_key, out_key, crypto_class=default_crypto_class):
324 self.bf_out = crypto_class(out_key) 332 self.bf_out = crypto_class(out_key)
325 self.bf_in = crypto_class(in_key) 333 self.bf_in = crypto_class(in_key)
326 334