"함수 urlsafe b64encode()"의 두 판 사이의 차이

 
(같은 사용자의 중간 판 11개는 보이지 않습니다)
1번째 줄: 1번째 줄:
[[분류: Python]]
[[분류: base64]]
==개요==
==개요==
{{DISPLAYTITLE:함수 urlsafe_b64encode()}}
{{DISPLAYTITLE:함수 urlsafe_b64encode()}}
;함수 urlsafe_b64encode()
;함수 urlsafe_b64encode()
==PHP==
[[분류: PHP]]
{{참고|PHP urlsafe_b64encode()}}
{{소스헤더|with padding}}
<syntaxhighlight lang='php' run>
function urlsafe_b64encode($input)
{
    return strtr(base64_encode($input), '+/', '-_');
}
echo urlsafe_b64encode('Hello World'); # SGVsbG8gV29ybGQ=
</syntaxhighlight>
{{소스헤더|without padding}}
<syntaxhighlight lang='php' run>
function urlsafeB64Encode($input)
{
    return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
}
echo urlsafeB64Encode('Hello World'); # SGVsbG8gV29ybGQ
</syntaxhighlight>


==Python==
==Python==
[[분류: 파이썬]]
[[분류: Python]]
{{참고|파이썬 urlsafe_b64encode()}}
{{참고|파이썬 urlsafe_b64encode()}}
<syntaxhighlight lang='python' >
<syntaxhighlight lang='python' run>
from base64 import urlsafe_b64encode
from base64 import urlsafe_b64encode


16번째 줄: 36번째 줄:
==같이 보기==
==같이 보기==
* [[URL 안전 base64]]
* [[URL 안전 base64]]
 
* [[함수 urlsafe_b64decode()]]
==참고==
* https://docs.python.org/3/library/base64.html#base64.urlsafe_b64encode

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

1 개요[ | ]

함수 urlsafe_b64encode()

2 PHP[ | ]

with padding
function urlsafe_b64encode($input)
{
    return strtr(base64_encode($input), '+/', '-_');
}
echo urlsafe_b64encode('Hello World'); # SGVsbG8gV29ybGQ=
without padding
function urlsafeB64Encode($input)
{
    return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
}
echo urlsafeB64Encode('Hello World'); # SGVsbG8gV29ybGQ

3 Python[ | ]

from base64 import urlsafe_b64encode

s = b'Hello World'
print( urlsafe_b64encode(s) ) # b'SGVsbG8gV29ybGQ='

4 같이 보기[ | ]

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