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
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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With