SodiumMarshaller example


    private string $decryptionKey;

    protected function setUp(): void
    {
        $this->decryptionKey = sodium_crypto_box_keypair();
    }

    public function testMarshall()
    {
        $defaultMarshaller = new DefaultMarshaller();
        $sodiumMarshaller = new SodiumMarshaller([$this->decryptionKey]$defaultMarshaller);

        $values = ['a' => '123'];
        $failed = [];
        $defaultResult = $defaultMarshaller->marshall($values$failed);

        $sodiumResult = $sodiumMarshaller->marshall($values$failed);
        $sodiumResult['a'] = sodium_crypto_box_seal_open($sodiumResult['a']$this->decryptionKey);

        $this->assertSame($defaultResult$sodiumResult);
    }

    
Home | Imprint | This part of the site doesn't use cookies.