'Get the Keyczar class to use.
The class can be customized with the ENCRYPTED_FIELD_MODE setting. By default,
this setting is DECRYPT_AND_ENCRYPT. Set this to ENCRYPT to disable decryption.
This is necessary if you are only providing public keys to Keyczar.
Returns:
keyczar.Encrypter if ENCRYPTED_FIELD_MODE is ENCRYPT.
keyczar.Crypter if ENCRYPTED_FIELD_MODE is DECRYPT_AND_ENCRYPT.
Override this method to customize the type of Keyczar class returned.'

def get_crypt_class(self):

    crypt_type = getattr(settings, 'ENCRYPTED_FIELD_MODE', 'DECRYPT_AND_ENCRYPT')
    if (crypt_type == 'ENCRYPT'):
        crypt_class_name = 'Encrypter'
    elif (crypt_type == 'DECRYPT_AND_ENCRYPT'):
        crypt_class_name = 'Crypter'
    else:
        raise ImproperlyConfigured(('ENCRYPTED_FIELD_MODE    must    be    either    DECRYPT_AND_ENCRYPT    or    ENCRYPT,    not    %s.' % crypt_type))
    return getattr(keyczar, crypt_class_name)
