the browser-facing portion of osu!
at master 648 B view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6declare(strict_types=1); 7 8namespace App\Libraries; 9 10class Base64Url 11{ 12 public static function decode(string $value): ?string 13 { 14 return null_if_false(base64_decode(strtr($value, '-_', '+/'), true)); 15 } 16 17 public static function encode(string $value): string 18 { 19 // url safe base64 20 // reference: https://datatracker.ietf.org/doc/html/rfc4648#section-5 21 return rtrim(strtr(base64_encode($value), '+/', '-_'), '='); 22 } 23}