PHP code example of terpomoj / base64-url-helpers

1. Go to this page and download the library: Download terpomoj/base64-url-helpers 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/ */

    

terpomoj / base64-url-helpers example snippets


$encoded = base64_url_encode('🏳️‍⚧️🏳️‍🌈');

// $encoded is now '8J-Ps--4j-KAjeKap--4j_Cfj7PvuI_igI3wn4yI'

$encode = base64_url_encode('🏳️‍⚧️');
// $encode = '8J-Ps--4j-KAjeKap004jw'

$encode = base64_url_encode('🏳️‍⚧️', removePadding: false);
// $encode = '8J-Ps--4j-KAjeKap004jw=='

$decoded = base64_url_decode('8J-Ps--4j-KAjeKap--4j_Cfj7PvuI_igI3wn4yI');

// $decoded is now '🏳️‍⚧️🏳️‍🌈'

$decoded = base64_url_decode('8J-Ps--4j-KAjeKap--4j_Cfj7PvuI_igI3wn4yI!!!!!');
// $decoded is now '🏳️‍⚧️🏳️‍🌈'

$decoded = base64_url_decode('8J-Ps--4j-KAjeKap--4j_Cfj7PvuI_igI3wn4yI!!!!!', strict: true);
// $decodes is now false

$uuid = base64_url_encode(Uuid::uuid4()->getBytes());
// $uuid is now 'oRZS8dRtR-GfBdCbaHwtkw'