kgilden/php-digidoc

使用爱沙尼亚身份证进行文档签名和验证的库

v0.1.1 2014-07-15 13:57 UTC

This package is auto-updated.

Last update: 2024-09-21 20:41:11 UTC


README

Build Status

PHP DigiDoc 是一个用于使用爱沙尼亚身份证进行数字签名和验证的 PHP 库。

使用方法

<?php

use KG\DigiDoc\Api;
use KG\DigiDoc\Client;

// This file is generated by Composer
require_once 'vendor/autoload.php';

$api = new Api(new Client());

// First off, let's create a new envelope.
$envelope = $api->create();

// Add the files you want to get signed.
$envelope->addFile('/path/to/file.txt');
$envelope->addFile('/second/path/to/file.md');

// Add a signature or two. Signature takes in certificate id and certificate
// signature. You must retrieve these from the client using the browser plugin.
$envelope->addSignature($signature = new Signature('F1..20', '8F..C0'));

// Sync up with the server. For example, the previous signature is given
// a challenge, which the client must solve.
$api->update($envelope);

printf("Challenge: %s\n", $signature->getChallenge());

// Set the solution for the given signature. This is computed by the borwser
// plugin.
$signature->setSolution('F6..00');

// Sync up with the server once more to send the solution.
$api->update($envelope);

// Time to write it on the disc.
$api->write('/tmp/my-newly-created-envelope.bdoc');

// Make sure to "close" the envelope (basically closes the session in the
// remote DigiDoc service).
$api->close($envelope);

安装

使用 Composer 安装 kgilden/php-digidoc

要求

  • PHP >= 5.3.8
  • (如果您使用的是基于 Debian 的发行版,需要 php-soap)

贡献

查看 CONTRIBUTING.md 文件。

运行测试

运行 phpunit 就这么简单。

许可证

PHP DigiDoc 在 MIT 许可证下发布。有关详细信息,请参阅附带 LICENSE 文件。