Reputation: 17469
I have a base64 string like this = "pCZXOVjpnlePyDk6znZrSw==" i need a encoder/decoder to convert it to decimal string like this = "84587163248712923874"
Is there any codec that do it?
Upvotes: 2
Views: 3716
Reputation: 31
Base64 encode/decode is part of the default libraries now (finally). Look at the class javax.xml.bind.DatatypeConverter. In there you will find two methods printBase64Binary and parseBase64Binary (along with a few other conversion routines).
Upvotes: 2
Reputation: 15693
You probably need a two stage process:
16 bytes is too big for a Java long so I assume that you will need a BigInteger
. There is a BigInteger
constructor that takes a byte array as parameter, though you will need to be careful with the sign bit. The toString()
method for the BigInteger
will give you the string you want.
Upvotes: 2