openssl_public_encrypt()和openssl_private_encrypt()的输出 [英] Output of openssl_public_encrypt() and openssl_private_encrypt()

查看:196
本文介绍了openssl_public_encrypt()和openssl_private_encrypt()的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解几件事

  • openssl_public_encrypt()和openssl_private_encrypt()函数的输出是什么?
  • 上述功能(加密数据)的输出,将对网络安全吗?
  • 如何在网站之间传输生成的加密数据?

推荐答案

openssl_public_encrypt()使用公钥加密消息,以便只有相应的私钥才能对其进行解密.这是用来保护信息,以防不应该看到的人看到.

openssl_public_encrypt() encrypts a message with a public key so that only the corresponding private key can decrypt it. This is used for protecting information against being seen by people who shouldn't.

openssl_private_encrypt()使用私钥加密消息,以便拥有相应公钥的任何人都可以解密该消息.这是 not ,用于保护信息免受不希望看到的眼睛的侵害,它用于制作数字签名,以帮助验证数据是否已被修改.通常,您不应该使用此功能;改用 openssl_sign() openssl_verify().

openssl_private_encrypt() encrypts a message with a private key so that it can be decrypted by anyone who has the corresponding public key. This is not used for protecting information against unwanted eyes, it's used for making digital signatures to help verify that the data hasn't been modified. You generally shouldn't use this function; use openssl_sign() and openssl_verify() instead.

加密和签名通常一起使用:您获取数据,使用自己的私钥对其进行签名(使用 openssl_sign()),然后对其进行加密(使用 openssl_public_encrypt())和收件人的公共密钥.将签名和加密后的邮件发送给收件人,收件人可以使用其私钥对邮件进行解密(使用 openssl_private_decrypt()),并验证签名(使用 openssl_verify())与您的公共密钥.这样可以确保在传输过程中,没有人可以阅读篡改消息,这可能就是您所说的网络安全"的意思.

Encryption and signing are typically used together: you take your data, sign it (using openssl_sign()) with your own private key, and then encrypt it (using openssl_public_encrypt()) with the recipient's public key. Send both the signature and the encrypted message to the recipient, and the recipient can decrypt the message (using openssl_private_decrypt()) with his private key, and verify the signature (using openssl_verify()) with your public key. This ensures that no one can read or tamper with the message while it's in transit, which is probably what you mean by "web-safe".

对于在网站之间传输数据,您可以按照任何需要的方式进行.HTTP,FTP,电子邮件,API调用等.加密和签名的全部要点是,您不必使用任何特殊方法即可安全地传输邮件.

As for transferring data between websites, you can do that in any way you want. HTTP, FTP, email, API calls, whatever. The whole point of encryption and signing is that you don't have to use any special means to transfer the message securely.

这篇关于openssl_public_encrypt()和openssl_private_encrypt()的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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