6 Replies - 20214 Views - Last Post: 18 March 2019 - 01:16 PM

#1 shango11   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 78
  • Joined: 06-July 11

is there a DatatypeConverter for the android?

Posted 26 November 2012 - 07:18 PM

I recently tried to use DatatypeConverter and to my surprise there is no such thing for the androind, is there an equivalent I can use?
Is This A Good Question/Topic? 1
  • +

Replies To: is there a DatatypeConverter for the android?

#2 H3R3T1C   User is offline

  • Android Expert
  • member icon

Reputation: 278
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: is there a DatatypeConverter for the android?

Posted 26 November 2012 - 07:26 PM

The is no "equivalent" to that in android but I bet there are other ways to accomplish what you are trying to do in android. What is it that you are trying to do?
Was This Post Helpful? 1
  • +
  • -

#3 shango11   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 78
  • Joined: 06-July 11

Re: is there a DatatypeConverter for the android?

Posted 26 November 2012 - 07:31 PM

I'm trying to do something along the lines of:
byte[] b2 = DatatypeConverter.parseBase64Binary(res);


Was This Post Helpful? 0
  • +
  • -

#4 H3R3T1C   User is offline

  • Android Expert
  • member icon

Reputation: 278
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: is there a DatatypeConverter for the android?

Posted 26 November 2012 - 07:48 PM

Try the Base64 class. http://developer.and...til/Base64.html
I dont think whitespace is allowed when using .decode(...) so make sure to remove all whitespace from the base64 string
Was This Post Helpful? 1
  • +
  • -

#5 shango11   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 78
  • Joined: 06-July 11

Re: is there a DatatypeConverter for the android?

Posted 26 November 2012 - 08:13 PM

View PostH3R3T1C, on 26 November 2012 - 07:48 PM, said:

Try the Base64 class. http://developer.and...til/Base64.html
I dont think whitespace is allowed when using .decode(...) so make sure to remove all whitespace from the base64 string


Exactly what I needed! Thanks for the help!
Was This Post Helpful? 0
  • +
  • -

#6 akshaytestpress   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-March 19

Re: is there a DatatypeConverter for the android?

Posted 15 March 2019 - 01:33 AM

View PostH3R3T1C, on 26 November 2012 - 07:48 PM, said:

Try the Base64 class. http://developer.and...til/Base64.html
I dont think whitespace is allowed when using .decode(...) so make sure to remove all whitespace from the base64 string


What will be the equivalent for
byte[] hmac = hasher.doFinal(payload.getBytes());
DatatypeConverter.printHexBinary(hmac);
Was This Post Helpful? 0
  • +
  • -

#7 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Re: is there a DatatypeConverter for the android?

Posted 18 March 2019 - 01:16 PM

Similar function in pure java, should work on droid, found on stack

private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
    char[] hexChars = new char[bytes.length * 2];
    for ( int j = 0; j < bytes.length; j++ ) {
        int v = bytes[j] & 0xFF;
        hexChars[j * 2] = hexArray[v >>> 4];
        hexChars[j * 2 + 1] = hexArray[v & 0x0F];
    }
    return new String(hexChars);

String myByteString = bytesToHex(hmac);



source
https://stackoverflo...-string-in-java
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1