django-extensions/django-extensions — pull request #205 by tschundler (2012-04-26 00:10:18+00:00)
Title: Updated to encrypted fields to truncate if necessary before encryption

If an encrypted field exceeds the maximum length the DB supports it gets truncated by the database, only raising a warning and allowing execution to continue.
If an attempt is made to read that same field back, decryption fails on the truncated data, and not only has part of the data been lost, it is now completely unreadable.

This addresses that by reporting a more accurate size to the database layer when creating tables, and truncating as necessary before data is passed on to the database. Therefore data written will be successfully read back.

It also removes the particularly incorrect size adjustment done is the EncryptedCharField field, which assumed the length of the encrypted data is the same as unencrypted, which is incorrect given the initialization vector and base64 encoding.