PHP code example of 3neti / truth-qr

1. Go to this page and download the library: Download 3neti/truth-qr 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/ */

    

3neti / truth-qr example snippets


use LBHurtado\TruthQr\Contracts\RecordService;
use LBHurtado\TruthQr\Core\RecordPayload;

$service = app(RecordService::class);
$scans = $service->encodeRecord(new RecordPayload('aes-election-v1', 'ballot', $ballotFields));
$decoded = $service->decodeRecord('aes-election-v1', $scans);

$decoded->recordType;       // ballot
$decoded->fields;           // verified, domain-decoded record
$decoded->canonicalPayload; // reassembled canonical bytes

use LBHurtado\TruthQr\Core\TruthQr;
use LBHurtado\TruthQr\Election\SignedElectionRecordDriver;

$truthQr = app(TruthQr::class);
$truthQr->register(app(SignedElectionRecordDriver::class));

$scans = $truthQr->encode('aes-election-v2', 'ballot', $ballot);
$verified = $truthQr->decode('aes-election-v2', $scans);