note 98982 added to function.openssl-sign

From: Date: Tue, 20 Jul 2010 12:53:20 +0000
Subject: note 98982 added to function.openssl-sign
Groups: php.notes 
Request: Send a blank email to php-notes+get-170986@lists.php.net to get a copy of this message
The list of Signature Algorithms (constants) is very limited! Fortunately the newer versions of php/openssl allow you to specify the signature algorithm as a string. You can use the 'openssl_get_md_methods' method to get a list of digest methods. Only some of them may be used to sign with RSA private keys. Those that can be used to sign with RSA private keys are: md4, md5, ripemd160, sha, sha1, sha224, sha256, sha384, sha512 Here's the modified Example #1 with SHA-512 hash: <?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 with SHA-512 openssl_sign($data, $signature, $pkeyid, "sha512"); // free the key from memory openssl_free_key($pkeyid); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 41.134.19.138 ---- Manual Page -- http://www.php.net/manual/en/function.openssl-sign.php Edit -- https://master.php.net/note/edit/98982 Del: integrated -- https://master.php.net/note/delete/98982/integrated Del: useless -- https://master.php.net/note/delete/98982/useless Del: bad code -- https://master.php.net/note/delete/98982/bad+code Del: spam -- https://master.php.net/note/delete/98982/spam Del: non-english -- https://master.php.net/note/delete/98982/non-english Del: in docs -- https://master.php.net/note/delete/98982/in+docs Del: other reasons-- https://master.php.net/note/delete/98982 Reject -- https://master.php.net/note/reject/98982 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170986) next »