Kecman
Kecman

Reputation: 21

How to create base64Binary representation of ByteArray?

I'm working on an android client for a Restful service. In short I have to send a request which looks like this:

<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<RSAKeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\">
    <Modulus>AKbIANPft2ug1a9Dht9GENdd5HtSdaEngCkbPYlz2syeulOpYJrS9UhRxvfWIlSPB3G1tJEGS5mibQtLcDS9zlnwsg8IoJ8Pq9Dd8XWmBa6oUYeotjA90YhC5F06085yew8nqPTOikdhpmBJT7AAmp9elnkSoVASD0WQnn1KqkCR</Modulus>
    <Exponent>AQAB</Exponent>
</RSAKeyValue>

The Modulus and the Exponent are both ByteArrays, but when they go through the Marshaller they look like above. If I pass to the OutputStream a simple ByteArray, my request looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RSAKeyValue xmlns="http://www.w3.org/2000/09/xmldsig#">
    <Modulus>[B@b2f43ee0</Modulus>
    <Exponent>[B@b2f43f90</Exponent>
</RSAKeyValue>

Which the server can't process. So my question is, how to get those Strings?

Upvotes: 1

Views: 67

Answers (1)

Kecman
Kecman

Reputation: 21

Solved it!

import android.util.Base64;

Base64.encode(<data>, Base64.DEFAULT)

Upvotes: 1

Related Questions