是否有任何文档或示例/教程如何让EncryptedCharField在Django模型中运行?
我花了很多时间在我的django项目中安装django-extension + keyczar等。没有doc如何安装它。
这是到目前为止:
pip install django-extensions
将'django_extensions'添加到INSTALLED_APPS
pip install python-keyczar
使用EncryptedCharField
创建了一个模型+添加的字段添加了ENCRYPTED_FIELD_KEYS_DIR ='../../../ enc-keys'
已下载KeyczarTool-0.71g-090613.jar
运行以下命令:java -jar KeyczarTool-0.71g-090613.jar create --location =。/ enc-keys --purpose = crypt --name =“first key”--asymmetric = rsa
到目前为止一切顺利,但是当我运行我的服务器时,我收到以下错误:
keyczar.errors.KeyNotFoundError:带有hash_val标识符的密钥未找到。
TRACEBACK
File "/Users/nv/Projects/project/models/client.py", line 78, in <module>
class Authorization(models.Model):
File "/Users/nv/Projects/project/models/client.py", line 86, in Authorization
iban_enc = EncryptedCharField(max_length=155)
File "/Users/nv/Projects/project/lib/python2.7/site-packages/django_extensions/db/fields/encrypted.py", line 121, in __init__
super(EncryptedCharField, self).__init__(*args, **kwargs)
File "/Users/nv/Projects/project/lib/python2.7/site-packages/django_extensions/db/fields/encrypted.py", line 32, in __init__
max_length = len(self.prefix) + len(self.crypt.Encrypt('x' * max_length))
File "/Users/nv/Projects/project/lib/python2.7/site-packages/keyczar/keyczar.py", line 338, in Encrypt
encrypting_key = self.primary_key
File "/Users/nv/Projects/project/lib/python2.7/site-packages/keyczar/keyczar.py", line 73, in <lambda>
primary_key = property(lambda self: self.GetKey(self.primary_version),
File "/Users/nv/Projects/project/lib/python2.7/site-packages/keyczar/keyczar.py", line 128, in GetKey
raise errors.KeyNotFoundError(key_id)
keyczar.errors.KeyNotFoundError: Key with hash_val identifier None not found.
我无法弄清楚我做错了什么。
答案 0 :(得分:4)
找到解决方案
创建后:
答案 1 :(得分:1)
找出JAVA(puach)的解决方案
试试这个
bin/keyczart create --location=keys --purpose=crypt --name=models && bin/keyczart addkey --location=keys --status=primary
确保密钥是项目中的文件夹,可能是/ var / keys ??或者你喜欢的地方
欢呼声