The equals (=) characters at the end are removed. V2hhdCBkb2VzIDIgKyAyLjEgZXF1YWw_PyB-IDQĪs you can see, the slashes (/) are replaced with underscores (_) and the plus (+) symbols are replaced with hyphens (-). The same data encoded as a Base64 URL encoded string is as follows. Note that I’ve used the question mark (?) characters and the tilde (~) character in the sample string to force the slash (/) and plus (+) characters to form part of the output. Given the text “What does 2 + 2.1 equal? ~ 4” the output of the Base64 encoding is as follows. Comparisonįor the sake of simplicity, let’s look at an example of converting some plain text to Base64 (as opposed to thinking of things in terms of binary data). Additionally, the equals (=) padding characters are often omitted. Base64 decoding logic will often validate the length of a Base64 string before decoding it.īase64 URL encoding uses the same characters as Base64 except for the last two from the list above which are replaced by the underscore (_) and hyphen (-) characters respectively. In the Base64 standard the equals (=) character is used as a ‘padding’ character in addition to the above set of 64 characters to make the string always divisible by 4. Charactersīase64 is named as such because it uses 64 different characters to encode data, as follows. If you are interested in a more detailed explanation of how Base64 encoding works, I recommend looking at the Base64 page on Wikipedia, which provides a more in-depth breakdown. In this section, I will provide a simple breakdown and comparison of Base64 against Base64 URL encoding. In this article, I will explain how Base64 URL encoding works in comparison to normal Base64 and show how you can work with Base64 URL encoding using C#. This is where Base64 URL encoding saves the day, helping to prevent issues like double encoding and routing errors. Having said that, the Base64 standard can be troublesome when it comes to transferring data in HTTP headers and URL query strings. This is especially true in a web context where everything tends to be based on text content i.e. It is useful in a wide variety of scenarios and makes it easier to transfer and store data in many cases. Base64 is an encoding scheme that allows binary data to be converted to text and back again.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |