Base64 online encoder/decoder
Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding. Each base64 digit represents exactly 6 bits of data.
Base64 URL safe example
Base64 in PHP
Encode URL safe
function urlsafeEncode(string $input) {
return \str_replace('=', '', \strtr(\base64_encode($input), '+/', '-_'));
}
Decode URL safe
urlsafeDecode(string $input, bool $strict = false) {
$remainder = \strlen($input) % 4;
if ($remainder) {
$padlen = 4 - $remainder;
$input .= \str_repeat('=', $padlen);
}
return \base64_decode(\strtr($input, '-_', '+/'), $strict);
}
Base64 in Python
Encode URL safe
base64.urlsafe_b64encode("Test")
Decode URL safe
base64.urlsafe_b64decode("Test")
Base64 in Go
Encode URL safe
_, err := b64.RawURLEncoding.EncodeToString([]byte(data))
Decode URL safe
_, err := b64.RawURLEncoding.DecodeString(str)
Base64 in C#
Encode URL safe
Base64UrlEncoder.Encode(StringToEncode);
Decode URL safe
Base64UrlEncoder.Decode(encodedStr)
Base64 in Rust
Encode URL safe
base64_url::encode("Hello, world!"))
Decode URL safe
base64_url::decode("SGVsbG8sIHdvcmxkIQ")
Base64 in Javascript
Encode URL safe
Buffer.from(token).toString('base64url')