php的openssl sign,php openssl_sign签名与openssl_verify校验使用实例

语法:

openssl_sign(“要签名的数据”,”签名后返回来的数据”,”签名的私钥”)

openssl_verify((“要签名的数据”, ”签名后返回来的数据”,”签名的公钥”, $signature_alg = OPENSSL_ALGO_SHA1) { }

返回的是0,即签名不正确,返回1,表示签名验证通过

事先要有对应的公私钥

$private_key_pem="-----BEGIN PRIVATE KEY-----

MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAMY4RLgInSxdWv0V

QJ030tCI0/KwGpS53g79KWJcOWfGHlHJFbc6mFE/GRGxJoPcMsQCCcqZyPreAw9p

A+aSX6QMzl0tOzdXq1HpkNLZ10cnLoAwA02pkwG/KVdjMtCfptZn4aPs2Fm+0aLl

8SwIwGCAI/iFooumXlOxKahraqB3AgMBAAECgYEAlD7E9jZLBkETqa/ZUTvMyPVs

PlcCqjSQJPmll9CNhlUfm98eBJkoDat5Hkg1G+z1cq5rkECPlT+xXjcWGb1jFMcE

3YLJOENxKFxGAWGvdmkKABmKee0ZxfrruTFpZZCNxnk8bpZcRI/y51G5yORduAfq

41AxWlYHE5A9ABG+qOECQQDnbE9/RRbabHTaGr6z1xqddA/KfkeRf2sbnH1+YSWW

7GOsw5yS6AJHLeAKU4oqjk+jf5DNnJFp2Plo+qSrpnuZAkEA20VC8gtrunDz/gkQ

7BgYRSibZQk91gnbiXqB5A2qMC+wS1nSkEZBUhl9ySGKhTag8gU2Ux

你可能感兴趣的:(php的openssl,sign)