PHP code example of markuspaks / xades-tools

1. Go to this page and download the library: Download markuspaks/xades-tools 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/ */

    

markuspaks / xades-tools example snippets


use XadesTools\Settings;
use XadesTools\Signature;
$settings = new Settings($pathToCertificate, $passphrase);
$xades = new Signature($settings);
$signedXmlAsString = $xades->signFile($file, $embed);

use XadesTools\Verification;
$xades = new Verification();
$result = $xades->verifyFile($pathToXadesFile);
if ($result) {
    $content = $res->content; // binary content or plain text for xml files
    $signTime = $res->dateSigned; // DateTime object
    $signingSubject = $res->signingSubject; // array
} else {
    // Signature does not match signed content
}
shell
php bin/sign.php file cert pass [embed] [load-content]
shell
php src/verify.php file [verbose]
shell
php src/extract.php file output