Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2011
    Posts
    21
    Rep Power
    0

    Default Base64 -> hexadecimal string decoder

    Hi,

    I have a base64 encoded string and I want to decode this to hexadecimal.

    Can anyone help me?

    Thanks in advance.

    Regards,

    Naveen Paul

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Base64 -> hexadecimal string decoder

    Can you give a small example?
    Are you asking how to convert and format the base64 String into a String of hexadecimal chatacters?
    There would be two steps: convert the base64String to bytes
    Then those bytes converted to a String of hexadecimal characters.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Join Date
    Mar 2011
    Posts
    21
    Rep Power
    0

    Default Re: Base64 -> hexadecimal string decoder

    Exactly..Thats is what I am looking for.

    Please browse the following url

    Tomasz Ostrowski - Base64 decoder

    say base64 string is : Zb4+GmaF1jRbGdCxk7RxXjSzqpEvgU1i0eHI7er0HUk=
    and hexadecimal string that I want is: 65BE3E1A6685D6345B19D0B193B4715E34B3AA912F814D62D1 E1C8EDEAF41D49

    Can you please provide the coding too?

    Thanks in advance

    Naveen Paul

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Base64 -> hexadecimal string decoder

    There are packages that will do the base64 decoding. I think apache has one. Or if you have another use that.

    When you get the bytes from the decoder(I think it should be a byte array) then you can use the Integer class's toHexString() method to convert each byte to a String of 2 hex digits. You will have to pad the values less than 16 with a leading "0"
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Base64 -> hexadecimal string decoder

    Duplicate thread has been closed. Original poster -- please follow the forum rules that you agreed to on signing up, including posting only one thread per question.

  6. #6
    Join Date
    Mar 2011
    Posts
    21
    Rep Power
    0

    Default Re: Base64 -> hexadecimal string decoder

    Hi
    We tried the below code but we are not getting desired output.
    import java.io.*;
    import org.apache.commons.codec.binary.Base64;
    import java.lang.Class;

    public class Test {
    public static void main(String[] args) throws IOException {

    String s = "Zb4+GmaF1jRbGdCxk7RxXjSzqpEvgU1i0eHI7er0HUk=" ;

    byte[] encodedBytes = Base64.encodeBase64(s.getBytes());

    // System.out.println(encodedBytes);
    for (int j = 0; j < encodedBytes.length; j++) {
    String hex = Integer.toHexString(encodedBytes[j]);
    System.out.print(hex);
    }

    }
    }

    Can you please check and help us if we are wrong on this.

    Thanks,
    Naveen

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Base64 -> hexadecimal string decoder

    Can you post the output from the program and show what is wrong with it?

    Why are you calling the encode method?
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. pc to xml to xml-decoder to mac
    By rowruffdesign in forum XML
    Replies: 0
    Last Post: 06-21-2011, 10:37 AM
  2. Decode base64 string to an image(pdf, png, ....)
    By RohitBBorse in forum New To Java
    Replies: 0
    Last Post: 05-25-2011, 01:07 PM
  3. image encoder decoder
    By fayiza in forum Java 2D
    Replies: 1
    Last Post: 09-19-2010, 05:55 PM
  4. How to convert a String into an Hexadecimal ?
    By ze snow in forum New To Java
    Replies: 7
    Last Post: 02-16-2010, 10:31 PM
  5. PNG file format decoder in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-21-2008, 08:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •