Download the PHP package leon-mbs/ppolib without Composer
On this page you can find all versions of the php package leon-mbs/ppolib. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download leon-mbs/ppolib
More information about leon-mbs/ppolib
Files in leon-mbs/ppolib
Package ppolib
Short Description Библиотека цифровой подписи для РРО (Украина)
License MIT
Homepage https://github.com/leon-mbs/ppolib
Informations about the package ppolib
Библиотека для наложения цифровой подписи (КЕП) согласно ДСТУ-4145
Большинство кода портировано с https://github.com/dstucrypt/jkurwa
Установка
composer require leon-mbs/ppolib
Как использовать
Распаковка ключа и сертификата
$cert = \PPOLib\Cert::load($certdata) ;
$key = \PPOLib\KeyStore::load($keydata,$password,$cert ) ;
Где $certdata - содержимое файла сертификата $keydata - содержимое файла ключа $password - пароль к ключу
Поскольку распаковка происходит довольно медленно, обьекты $cert и $key следует положить в сессию или сериализовать и спрятать в надежном хранилище для дальнейшего использования
Загрузка jks файла (ПриватБанк) list($key,$cert) = \PPOLib\KeyStore::loadjks($jks,$password) ;
Подпись документа или команды
$signeddata= \PPOLib\PPO::sign($message,$key,$cert);
Открепленная подпись (без данных)
$signeddata= \PPOLib\PPO::sign($message,$key,$cert,true);
Подпись с TSP отметкой
$signeddata= \PPOLib\PPO::sign($message,$key,$cert,false,true);
Отправка запроса в налоговую
$answer = \PPOLib\PPO::send($signeddata,'cmd') ;
Если отправляется документ ответом будут подписанные данные, из которых нужно вынуть документ ответа (обычно xml)
$data = \PPOLib\PPO::decrypt($answer,true) ;
Если предполагать что ответ с налоговой будет подписан верно то второй параметр (проверка подписи) можно не указывать это ускорит обработку.
Получение информации о подписи
$info = \PPOLib\PPO::signinfo($answer) ;
Шифрование сообщения.
Использутся пара ключ-сертификат для шифрования а также сертификат получателя
\PPOLib\PPO::encode($message,$forcert,$key,$keycert );
Дещифрование сообщения.
Использутся ключ от сертификата получателя
\PPOLib\PPO::decode($message,$key );