22 lines
417 B
PHP
22 lines
417 B
PHP
<?php
|
|
namespace Froxlor\Http\LetsEncrypt;
|
|
|
|
class Base64UrlSafeEncoder
|
|
{
|
|
|
|
public static function encode($input)
|
|
{
|
|
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
|
|
}
|
|
|
|
public static function decode($input)
|
|
{
|
|
$remainder = strlen($input) % 4;
|
|
if ($remainder) {
|
|
$padlen = 4 - $remainder;
|
|
$input .= str_repeat('=', $padlen);
|
|
}
|
|
return base64_decode(strtr($input, '-_', '+/'));
|
|
}
|
|
}
|