支持多个解密密钥的Python加密方案

发布于 2025-01-05 06:10:12 字数 300 浏览 0 评论 0原文

是否有一个Python库支持(对称)数据加密,并且可以使用多个解密密钥。

我有(敏感)用户数据,必须加密存储在数据库中,但多个第三方必须可以访问这些数据,而无需向他们提供相同的秘密。

这可以通过生成随机密钥K,对原始数据D进行加密得到D_K来实现。然后,我根据需要使用尽可能多的访问密钥(ak_1 到 ak_n)加密 K,存储它们以供以后使用并销毁 K。每当第 3 方尝试访问 D 时,提交 ak_i,我用它来解密 K,并用它来解密 D_K 但是,最好能实现

一个,因为a)我不喜欢重新发明轮子,b)这是安全性的,你可能不会100%正确。

Is there a python library that supports (symmetric) encryption of data with the possibility of using multiple decryption keys.

I have (sensitive) user data that must be stored encrypted in a database, but it must be possible for multiple 3rd parties to access the data without giving them all the same secret.

This could be implemented by generating a random key K, encrypt the original data D to get D_K. Then I encrypting K with as many access keys (ak_1 to ak_n) as needed, store them for later use and destroy K. Whenever a 3rd party tries to access D the submit ak_i and I use it to decrypt K and us it to decrypt D_K to get D.

However, it would be nice to have a implemented since a) I don't like to reinvent the wheel and b) this is security and you probably won't get it 100% right.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风情万种。 2025-01-12 06:10:12

由于硬加密导出控制的混乱和问题,没有很多第三方库直接提供这种更高级别的显式加密方案。

在大多数情况下,您必须将诸如 PyCrypto 之类的工具集与您的自己的关键逻辑。然而,鉴于我们正在谈论的是加密货币,如果我没有指出 Python 中用于较低级别硬加密工具的其他库。

Due to the confusion and issues surrounding export controls of hard encryption, there's not a lot of 3rd party libraries that directly provide this sort of higher-level explicit encryption scheme.

For the most part you're going to have to wrap the toolset of something like PyCrypto with your own key logic. Seeing as it's crypto we're talking about, however, I'd be remiss if I didn't point out the other libraries for lower-level hard encryption tools in Python.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文