ciphersweet的python实现
ciphersweet的Python项目详细描述
Pyciphersweet
ciphersweet的python实现
这是https://github.com/paragonie/ciphersweet中ciphersweet的一个非常早期的实现 请不要试图在生产中使用这个,因为我不确定是否一切正常。有些测试与原始的ciphersweet测试匹配,并且这些测试当前正在通过。
目前,只支持“现代”模式。
下面是如何创建数字最后四位数字的加密字段的示例:
import ciphersweet
import secrets
nacl_key = secrets.token_bytes(32)
field = ciphersweet.EncryptedField(
base_key=nacl_key,
table='contacts',
field='ssn',
)
t = ciphersweet.Transformation.last_four_digits
field.add_blind_index('contact_ssn_last_four', t, output_length=16, fast=True)
index = field.get_blind_index('hello', name='contact_ssn_last_four')
print(index['value'])
有关如何工作的文档,请查看原始的ciphersweet项目。