Voting

: five plus zero?
(Example: nine)

The Note You're Voting On

Daniel Klein
2 years ago
Improvement on "gutzmer at usa dot net", "biziclop at vipmail dot hu", and "ivanm at duck dot com".

<?php
function base64url_encode($data) {
return
rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}

function
base64url_decode($data) {
return
base64_decode(strtr($data, '-_', '+/'));
}
?>

None of the padding for strings longer than 4 characters worked. Padding the decode function with = is unnecessary, and has been since at least PHP 5.4 (as far back as I checked before posting) so I removed it.

<< Back to user notes page

To Top