dcwatson / django-pgcrypto

Python and Django utilities for encrypted fields using pgcrypto.
BSD 2-Clause "Simplified" License
67 stars 22 forks source link

AES issues on Python 3 #18

Closed jayfk closed 8 years ago

jayfk commented 8 years ago

I'm unable to create a migration using AES.

Blowfish seems to work:

date_hired = pgcrypto.EncryptedTextField(cipher='Blowfish', key='datekey')

But AES does'nt:

date_hired = pgcrypto.EncryptedTextField(cipher='AES', key='datekey')

Traceback


Traceback (most recent call last):
  File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/commands/makemigrations.py", line 106, in handle
ProjectState.from_apps(apps),
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/state.py", line 174, in from_apps
model_state = ModelState.from_model(model)
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/state.py", line 393, in from_model
fields.append((name, field.clone()))
  File "/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 464, in clone
return self.__class__(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pgcrypto/fields.py", line 24, in __init__
self.cipher_key = aes_pad_key(self.cipher_key.encode(self.charset))
AttributeError: 'bytes' object has no attribute 'encode'
jayfk commented 8 years ago

Works when installing directly from github. The PyPi release seems to be a bit dated. Any chance for a new release?

dcwatson commented 8 years ago

Pushed out 1.3.0 to PyPI