是否可以使用多个私钥(PHP)进行加密? [英] Is it possible to have encryption with multiple private keys (PHP)?

查看:179
本文介绍了是否可以使用多个私钥(PHP)进行加密?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

或者:如何为一群用户存储加密数据?

我承认这是一个愚蠢的问题,私钥是仅限于该术语已经暗示的一个人。但我有以下情况:

I admit, it's a silly question, a private key is limited to only one person as the term already implies. But I have the following scenario:

用户Tom输入需要在数据库中加密存储的数据。用户决定他希望将此信息提供给Jim和Bob。用户John和Jayne无法解密。当然也没有给用户Tim劫持服务器,并且可以访问加密数据和执行加密/解密的脚本。

User Tom enters data that needs to be stored encrypted in a database. The user decides he wants to make this information available to Jim and Bob. The users John and Jayne must not be able to decrypt it. Of course also not to user Tim who hacked the server and has access to the encrypted data and the scripts that do the encryption/decryption.

我认为公钥/私有使用PHP的关键方法 openssl_public_encrypt 功能不会在这里工作为两个用户需要拥有私有密钥来解密数据。

I think the public key/private key approach with PHPs openssl_public_encrypt function won't work here as two users need to have that "private" key to decrypt the data.

我猜这是一个相当笼统的问题,但如果重要的话,它必须在PHP中完成MySQL可能)。

I guess this a rather general question, but if it's important, it must be done in PHP (and MySQL maybe).

推荐答案

这是在OpenPGP(和其他系统)中如何完成:
- 您正在生成秘密对称密钥,用于加密数据本身;
- 然后,这个对称密钥用汤姆的密钥加密;
- 也可以使用Jim和Bob的公钥加密对称密钥,允许他们解密密钥,然后解密密钥。

That's how it done in OpenPGP (and, other systems): - you are generating secret symmetric key, which is used to encrypt the data itself; - then, this symmetric key is encrypted with Tom's key; - also, symmetric key can be encrypted with Jim's and Bob's public key, allowing them to decrypt the key and after that to decrypt the data

这篇关于是否可以使用多个私钥(PHP)进行加密?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆