downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  

<openssl_sealopenssl_verify>
Last updated: Thu, 26 Jun 2008

openssl_sign

(PHP 4 >= 4.0.4, PHP 5)

openssl_sign — Generate signature

Description

bool openssl_sign ( string $data , string &$signature , mixed $priv_key_id [, int $signature_alg ] )

openssl_sign() computes a signature for the specified data by using SHA1 for hashing followed by encryption using the private key associated with priv_key_id . Note that the data itself is not encrypted.

Parameters

data

signature

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

priv_key_id

signature_alg

Defaults to OPENSSL_ALGO_SHA1. For more information see the list of Signature Algorithms.

Return Values

Returns TRUE on success or FALSE on failure.

ChangeLog

Version Description
5.0.0 The signature_alg parameter was added.

Examples

Example #1 openssl_sign() example

<?php
// $data is assumed to contain the data to be signed

// fetch private key from file and ready it
$fp = fopen("/src/openssl-0.9.6/demos/sign/key.pem", "r");
$priv_key = fread($fp, 8192);
fclose($fp);
$pkeyid = openssl_get_privatekey($priv_key);

// compute signature
openssl_sign($data, $signature, $pkeyid);

// free the key from memory
openssl_free_key($pkeyid);
?>

See Also



add a noteadd a note User Contributed Notes
Generate signature
There are no user contributed notes for this page.




<openssl_sealopenssl_verify>
Last updated: Thu, 26 Jun 2008
show source | credits | sitemap | contact | advertising | mirror sites
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://phpbuilder.com/
Last updated: Tue Nov 1 20:20:59 2005 EST
Columns / Articles | Tips / Quickies | News | News Linking and RSS Feeds | Shared Code Library
Mail Archives | Support / Discussion Forums | Get Started! Links | Contribute! | Docs