PHP code example of marko / encryption

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

    

marko / encryption example snippets


use Marko\Encryption\Contracts\EncryptorInterface;

class TokenService
{
    public function __construct(
        private EncryptorInterface $encryptor,
    ) {}

    public function issueToken(array $payload): string
    {
        return $this->encryptor->encrypt(
            json_encode($payload, JSON_THROW_ON_ERROR),
        );
    }
}