Is it possible to obtain two identical encoded values for two different inputs to the Base64 encoding algorithm?
Let's use another algorithm for example, a function that replaces underscores with the letter X.
Foo_Bar = FooXBar
FooXBar = FooXBar
Can this sort of thing ever happen with Base64 encoding?
The short answer is yes, unique binary/hex values will always encode to a unique base64 encoded string.
Since there are only 26 letters in the English alphabet, a maximum of four binary bytes can be represented with three characters from the alphabet. This is where the '64' in Base64 encoding comes from - it can represent up to 64 different combinations using three out of six possible characters.
However, as we realized in practice, base64 decoder implementations are in- consistent across various systems, programming languages and software libraries.
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.
No, it cannot happen. Base64 is a lossless conversion (and it even needs a 33% space more). In math terms, the Base64 function is a bijection.
Note how HTTP basic access authentication use this encoding for the username and the password. Anyone can get the original strings from the encoded one, and for this reason this authentication should be used only under HTTPS.
You can find more details on Base64 also on Wikipedia.
No, base64 is just a way of encoding binary data as printable characters.
Strictly speaking, it's just a number system, like binary (base 2), decimal(base 10), or hexadecimal (base 16). Just as you can convert losslessly between those you can with base 64. In fact, mathematically bases are irrelevant, and are only used for notation and human use, math is equivalent no matter what base you use.
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