RFC 4648 section 4 defines the “base64” encoding that most programming languages implement by default: btoa(), PHP’s base64_encode(), Python’s b64encode(), Java’s Base64.getEncoder(), and so on.
Rules
- Alphabet:
A–Z a–z 0–9 + /(see Base64 characters). - Padding with
=so the length is always a multiple of 4. - No line breaks. RFC 4648 says implementations must not add line feeds unless a referring specification (like MIME) explicitly requires them.
- Decoders must reject characters outside the alphabet unless the referring specification says otherwise.
- Unused bits in the last character should be zero (canonical encoding); strict decoders may reject non-zero bits.
Validation regex
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$
This matches every valid padded value, including the empty string. Check your value interactively with the Base64 validator.
댓글 (0)
“Standard Base64 (RFC 4648)”에 대한 질문, 아이디어, 버그가 있으신가요? 댓글을 남기거나 도구를 평가하거나 다른 사람에게 답글을 달아 주세요.
아직 댓글이 없습니다. 첫 번째로 의견을 남겨 주세요!