Voting

: max(two, nine)?
(Example: nine)

The Note You're Voting On

alf at trance dot net
9 years ago
@gutzmer at usa dot net

Nice idea! However...

The function base64url_decode doesn't pad strings longer than 4 chars.
str_pad will only pad the string if the second argument is larger than the length of the original string. So the correct function should be:

<?php
function base64url_decode($data) {
$len = strlen($data);
return
base64_decode(str_pad(strtr($data, '-_', '+/'), $len + $len % 4, '=', STR_PAD_RIGHT));
}

Note that base64_decode works fine without the padding, that is why your function works.

<< Back to user notes page

To Top