Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is an empty string valid base64 encoded data of zero bytes length?

Tags:

One of my colleges was telling me that the empty string is not a valid base64 encoded data string. I don't think this is true (he is too lazy to parse it), but after googling around a bit and even checking the RFC I have not found any documentation that explicitly states how to properly encode a blob of zero bytes length in base64.

So, the question is: Do you have a link to some official documentation that explicitly states how zero bytes should be encoded in base64?

like image 364
Fozi Avatar asked Mar 04 '13 22:03

Fozi


People also ask

Is empty string valid Base64?

Every empty string is a valid Base64 string. Non-trivial cases are all remaining. Knowing the internals of Base64 encoding will help us as follows. Base64 encoding use the limited set of characters to represent the output.

How long is a Base64 encoded string?

BASE64 characters are 6 bits in length. They are formed by taking a block of three octets to form a 24-bit string, which is converted into four BASE64 characters.

What characters are invalid in Base64?

The base 64 digits in ascending order from zero are the uppercase characters 'A' to 'Z', lowercase characters 'a' to 'z', numerals '0' to '9', and the symbols '+' and '/'. % is not allowed in base64 encoding.


1 Answers

According to RFC 4648 Section 10, Test Vectors,

BASE64("") = "" 

I would assume the inverse must hold as well.

like image 114
Bondolin Avatar answered Sep 24 '22 17:09

Bondolin