- n_bytes = len(hashlib.new(self.algorithm).digest())
- if settings.DATABASE_ENGINE == 'postgresql':
- return 'bytea'
- elif settings.DATABASE_ENGINE == 'mysql':
- return 'binary(%d)' % n_bytes
+ if self.hashlib:
+ n_bytes = len(hashlib.new(self.algorithm).digest())
+ else:
+ n_bytes = len(self.hash_constructor().digest())
+ if settings.DATABASE_ENGINE.startswith('postgresql'):
+ return 'bytea'
+ elif settings.DATABASE_ENGINE == 'mysql':
+ return 'binary(%d)' % n_bytes
+ else:
+ raise Exception("Unknown database engine '%s'" % \
+ settings.DATABASE_ENGINE)