PHP code example of jose-chan / signature

1. Go to this page and download the library: Download jose-chan/signature library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jose-chan / signature example snippets




use JoseChan\Signature\SignAdaptor;

//签名
//hash签名
SignAdaptor::getInstance()->sign(
    $parameter_string,//待签名字符串
    $sign_key,//用于签名的key
    SignAdaptor::HASH
);

//RSA签名
SignAdaptor::getInstance()->sign(
    $parameter_string,//待签名字符串
    $private_key,//私钥
    SignAdaptor::RSA
);

//验签
//hash验签
SignAdaptor::getInstance()->verify(
    $parameter_string,//待签名字符串
    $sign,//签名
    $sign_key,//用于签名的key
    SignAdaptor::HASH
);

//RSA验签
SignAdaptor::getInstance()->sign(
    $parameter_string,//待签名字符串
    $sign,//签名
    $public_key,//公钥
    SignAdaptor::RSA
);