OpenSSL 함수 목록
PHP Manual

openssl_sign

(PHP 4 >= 4.0.4, PHP 5)

openssl_signGenerate signature

설명

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

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.

인수

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.

반환값

성공할 경우 TRUE를, 실패할 경우 FALSE를 반환합니다.

변경점

버전 설명
5.0.0 The signature_alg parameter was added.

예제

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($fp8192);
fclose($fp);
$pkeyid openssl_get_privatekey($priv_key);

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

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

참고


OpenSSL 함수 목록
PHP Manual