Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Base64 standardized?

In the company that I work, we have class to convert to and from Base64 string. When I first saw the code, I asked why don´t use the Convert.ToBase64String that comes with .NET?

Then I modified the method body to just call Convert.ToBase64String, but it don´t generate the same string.

I tried using ASCII, UTF8, Unicode and UTF32.

I dont remember exactly but I think that ASCII generates a string with the same length but some chars different, and others Enconding generates bigger strings.

Maybe our implementation was wrong, but I found a JavaScript implementations that matches ours.

Isn´t Base64 portable?

Edit: I found this at Wikipedia, but I don´t know if it was the cause http://en.wikipedia.org/wiki/Base64#Implementations_and_history

Edit2: I mentioned encodings because we are converting a string to another. Then I need to firstly convert my original string to a byte array using some encoding

like image 587
Felipe Pessoto Avatar asked Jan 30 '12 10:01

Felipe Pessoto


People also ask

Is Base64 encoding always the same?

Artjom B. Base64 is not encryption. But yes, different input strings will always encode to different Base64-encoded strings, and the same input string will always encode to the same Base64-encoded string. It's not a hash though, so small changes in the input will only result in small changes in the output.

What type of encoding is Base64?

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.

How efficient is Base64 encoding?

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.

What is the difference between Base64 and UTF 8?

UTF-8 is like the other UTF encodings a character encoding to encode characters of the Unicode character set UCS. Base64 is an encoding to represent any byte sequence by a sequence of printable characters (i.e. A – Z , a – z , 0 – 9 , + , and / ). There is no System.


2 Answers

RFC 3548. No, wait! There's a newer one: RFC 4648. (Thanks dtb!)

BTW, you seem to be mixing base64, which turns any binary stream into an ASCII stream and character encodings, which are totally different concepts. You may want to read this introduction article about encodings.

like image 145
Serge Wautier Avatar answered Oct 31 '22 05:10

Serge Wautier


There are at least 10 different implementations. They mostly differ by the char for index 62 and 63.

http://en.wikipedia.org/wiki/Base64#Implementations_and_history

like image 28
Kolja Avatar answered Oct 31 '22 06:10

Kolja