PHP code example of mikhailovlab / crypto-pro-builder
1. Go to this page and download the library: Download mikhailovlab/crypto-pro-builder 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/ */
mikhailovlab / crypto-pro-builder example snippets
protected ConsoleRunner $csp;
protected array $patterns;
protected ?array $pattern;
protected ?array $expectedFields;
protected bool $structureMatches;
protected array $methods;
public function __construct(string $command = 'csptest')
public function __call(string $name, array $arguments): self
public function registerMethods(array $customMethods): self
public function addKey(string $key): self
public function getContainers(bool $fullPath = true): self
public function checkContainer(?string $container = null, ?string $pass = null): self
public function changeContainerPass(?string $container = null, ?string $newPass = null, ?string $currentPass = null): self
public function copyContainer(): self
public function deleteContainer(?string $container = null): self
public function hashFile(string $filePath, string $alg = 'GR3411_2012_512'): self
public function verifyHash(array $files, string $alg = 'GR3411_2012_512'): self
public function signDocument(): self
public function verifySignature(array $files): self
public function encryptDocument(): self
public function decryptDocument(): self
public function certificatInstall(): self
public function getCertificates(): self
public function getCertificateByTp(): self
public function deleteCertificate(): self
public function encoding(string $code): self
public function decoding(): self
public function usePattern(?string $patternName = null, ?array $patternFields = null): self
public function useStructure(): self
public function addPatterns(array $patterns): self
private function structureMatches(array $matches, array $fields): array
try{
dd(new CryptoPro('cpverify')
->verifyHash(['H:\csp\123.txt', $hash]) //второй элемент хэш строка или путь к файлу
->run()
);
}catch (Exception $e){
dd($e->getMessage());
}
array:1 [▼ // app\Http\Controllers\TestController.php:25
"status" => "File 'H:\csp\123.txt' has been verified"
]
try{
dd(new CryptoPro()
->signDocument()
->in('H:\csp\123.txt')
->out('H:\csp\123.txt.sig')
->password('1234') //пароль, если требуется
->my('00dad6c045c2ec4a01f20441daf2d8dd999aaf07') // Сертификат
->addsigtime() //добавить время подписи, если требуется
->base64() // base64, если требуется
->detached() //отсоединенная подпись, если требуется
->add() //добавить сертификат, если требуется
->silent() //не выводить окно с вводом пароля
->run()
);
}catch (Exception $e){
dd($e->getMessage());
}
try{
dd(new CryptoPro()
->registerMethods(['install', 'delete']) //зарегистрировать дополнительные методы
->addKey("-nochain") //пробросить кастомный аргумент или ключ
->encoding('866') //добавить кодировку, например из 866 в UTF-8 (для кириллицы в windows)
->decoding() //вернуть исходную кодировку, если отдаем вывод в консоль
->addPatterns(['patternname' => 'regexp']) //добавить кастомные паттерны для парсинга
->usePattern("patternname") //использовать паттерн для парсинга
->run()
);
}catch (Exception $e){
dd($e->getMessage());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.