Files
opensourcepos/app/Helpers/url_helper.php
jekkos 0d1f4efe3c Extended payment delete fix (#4274)
* Create a  Base64 URL-Safe encoding and decoding helper

* Rename web_helper to url_helper

---------

Co-authored-by: El_Coloso <diegoramosp@gmail.com>
2025-07-07 13:57:03 +02:00

31 lines
702 B
PHP

<?php
if (!function_exists('base64url_encode')) {
/**
* Encode data to Base64 URL-safe string.
*
* @param string $data
* @return string
*/
function base64url_encode($data)
{
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
}
if (!function_exists('base64url_decode')) {
/**
* Decode Base64 URL-safe string to original data.
*
* @param string $data
* @return string|false
*/
function base64url_decode($data)
{
$remainder = strlen($data) % 4;
if ($remainder) {
$data .= str_repeat('=', 4 - $remainder);
}
return base64_decode(strtr($data, '-_', '+/'));
}
}