"PHP urlsafeB64Decode()"의 두 판 사이의 차이

잔글 (Jmnote님이 PHP urlsafe b64decode() 문서를 PHP urlsafeB64Decode() 문서로 이동했습니다)
 
(같은 사용자의 중간 판 3개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;PHP urlsafeB64Encode()
;PHP urlsafeB64Decode()


{{소스헤더|with padding}}
{{소스헤더|with padding}}
12번째 줄: 12번째 줄:
{{소스헤더|without padding ★}}
{{소스헤더|without padding ★}}
<syntaxhighlight lang='php' run>
<syntaxhighlight lang='php' run>
# https://github.com/firebase/php-jwt/blob/feb0e820b8436873675fd3aca04f3728eb2185cb/src/JWT.php#L333
function urlsafeB64Decode($input)
function urlsafeB64Decode($input)
{
{
20번째 줄: 19번째 줄:
         $input .= str_repeat('=', $padlen);
         $input .= str_repeat('=', $padlen);
     }
     }
    return base64_decode(strtr($input, '-_', '+/'));
}
echo urlsafeB64Decode('SGVsbG8gV29ybGQ'); # Hello World
</syntaxhighlight>
<syntaxhighlight lang='php' run>
function urlsafeB64Decode($input)
{
     return base64_decode(strtr($input, '-_', '+/'));
     return base64_decode(strtr($input, '-_', '+/'));
}
}
29번째 줄: 35번째 줄:
* [[PHP urlsafe_b64encode()]]
* [[PHP urlsafe_b64encode()]]
* [[함수 urlsafe_b64decode()]]
* [[함수 urlsafe_b64decode()]]
==참고==
* https://gist.github.com/muffycompo/a378dcfa73c3cf354eb8
* https://github.com/firebase/php-jwt/blob/feb0e820b8436873675fd3aca04f3728eb2185cb/src/JWT.php#L333


[[분류: PHP]]
[[분류: PHP]]
[[분류: base64]]
[[분류: base64]]

2021년 7월 19일 (월) 11:24 기준 최신판

1 개요[ | ]

PHP urlsafeB64Decode()
with padding
function base64url_decode($input) { 
    return base64_decode(strtr($input, '-_', '+/').str_repeat("=",-strlen($input) & 3));
} 
echo base64url_decode('SGVsbG8gV29ybGQ='); # Hello World
without padding ★
function urlsafeB64Decode($input)
{
    $remainder = strlen($input) % 4;
    if ($remainder) {
        $padlen = 4 - $remainder;
        $input .= str_repeat('=', $padlen);
    }
    return base64_decode(strtr($input, '-_', '+/'));
}
echo urlsafeB64Decode('SGVsbG8gV29ybGQ'); # Hello World
function urlsafeB64Decode($input)
{
    return base64_decode(strtr($input, '-_', '+/'));
}
echo urlsafeB64Decode('SGVsbG8gV29ybGQ'); # Hello World

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}