I am currently working on a project which need 64-bit decoding after some research I found these two methods in java itself,
from JAVA 8
import java.util.Base64;
byte[] decodedBytes = Base64.getDecoder().decode("encodedUserPassword");
from JAVA 6
import javax.xml.bind.DatatypeConverter;
byte[] decodedBytes = DatatypeConverter.parseBase64Binary("encodedUserPassword");
What I want to know is why was there a need for Base64
if DatatypeConverter
was already present?
Is there a different performance wise?
The entire javax.xml.bind module is deprecated (even removed) on Java9 https://docs.oracle.com/javase/9/docs/api/java.xml.bind-summary.html
If your projects are using Java8 onward, then cease using that package and use instead Java8's Base64 class, so that future Java upgrades won't affect them.
On the other hand, if you must keep compatibility with Java7 or prior, you can't use Base64 (as it was introduced on Java8). For that, you should either keep using DatatypeConverter or, even better, another standalone library to encode/decode in base 64 (such as Apache Commons 64 )
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