Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base64 encoded data maximum size

I have a security mechanism that implements symmetric algorithm RijndaelManaged. I managed to find information what is the maximum size of encrypted data using RijndaelManaged for particular IV. According to my calculations it will be 128 bytes. However I need to convert these 128 bytes to string using Base64. Is there a way to calculate maximum number of chars that Base64 encoding will use to encode input byte array of size 128?

Thanks,Pawel

like image 912
dragonfly Avatar asked Sep 30 '11 10:09

dragonfly


People also ask

How much bigger is Base64-encoded data?

Encoded size increase This means that the Base64 version of a string or file will be at least 133% the size of its source (a ~33% increase). The increase may be larger if the encoded data is small.

How big can a Base64 string be?

Length of data The output is an ascii string. Base64 uses 4 ascii characters to encode 24-bits (3 bytes) of data. To encode, it splits up the three bytes into 4 6-bit numbers. A 6-bit number can represent 64 possible value.

How big can a Base64 image be?

about 4 or 8kb.

Is space allowed in Base64?

By reading the http://en.wikipedia.org/wiki/Base64 wiki it seems that in Base64 transfer encoding for MIME (RFC 2045) spaces are allowed and discarded. In all other variants they are forbidden.

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.

Does converting to Base64 reduce size?

Although Base64 is a relatively efficient way of encoding binary data it will, on average still increase the file size for more than 25%. This not only increases your bandwidth bill, but also increases the download time.


1 Answers

Absolutely - Base64 takes 4 characters to represent every 3 bytes. (Padding is applied for binary data which isn't an exact multiple of 3 bytes.) So 128 bytes will always be 172 characters. (The way to work this out is that base64 represents 6 bits in each character (26 = 64); therefore 3 bytes = 24 bits = 4 base-64 characters.)

like image 172
Jon Skeet Avatar answered Oct 25 '22 12:10

Jon Skeet