openssl_sign

PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8
openssl_sign - Generate signature
Manual
Code Examples

openssl_sign(
     string$data,
     stringsignature,
     OpenSSLAsymmetricKey|OpenSSLCertificate|array|string$private_key,
     [string|int$algorithm = OPENSSL_ALGO_SHA1]
): bool

openssl_sign computes a signature for the specified data by generating a cryptographic digital signature using the private key associated with private_key. Note that the data itself is not encrypted.

Parameters

data

The string of data you wish to sign

signature

If the call was successful the signature is returned in signature.

private_key

OpenSSLAsymmetricKey - a key, returned by openssl_get_privatekey

string - a PEM formatted key

algorithm

int - one of these Signature Algorithms.

string - a valid string returned by openssl_get_md_methods example, "sha256WithRSAEncryption" or "sha384".

Return Values

Returns true on success or false on failure.

Changelog

Version Description
8.0.0 private_key accepts an OpenSSLAsymmetricKey or OpenSSLCertificate instance now; previously, a resource of type OpenSSL key or OpenSSL X.509 was accepted.

Related Functions

Example of openssl_sign

Show all examples for openssl_sign

PHP Version:


Function openssl_sign:

OpenSSL Functions

Most used PHP functions