PHP 手冊
前一頁 |  | 下一頁

# openssl_public_encrypt

(PHP 4 >= 4.0.6, PHP 5)

openssl_public_encrypt -- Encrypts data with public key

## Description

bool openssl_public_encrypt ( string data, string &crypted, mixed key [, int padding] )

警告
這個函數是實驗性質的。這個函數的行為、名稱、和關於此函數的任何其他文件在未來PHP的發行中可能會在不通知的情況下改變。 使用此延伸需自行承擔風險。

openssl_public_encrypt() encrypts data with public key and stores the result into crypted. Encrypted data can be decrypted via openssl_private_decrypt(). padding defaults to `OPENSSL_PKCS1_PADDING`, but can also be one of `OPENSSL_SSLV23_PADDING`, `OPENSSL_PKCS1_OAEP_PADDING`, `OPENSSL_NO_PADDING`.

成功回傳`TRUE`失敗回傳`FALSE`。

This function can be used e.g. to encrypt message which can be then read only by owner of the private key. It can be also used to store secure data in database.

See also openssl_private_decrypt() and openssl_private_encrypt().

前一頁 | 內容 | 下一頁
openssl_public_decrypt | 上一層 | openssl_seal