Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I need to convert 323830303030346434313461343135383538346435323462343134343535333833303339333033363030303164346330303130313031313630343031303130353165303030653038316130643164303435323236

to 2800004d414a4158584d524b41445538303930360001d4c001010116040101051e000e081a0d1d045226

where 32 is the asci of 2 , 38 of 8 . 30 of 0 etc

Any help ?

Thanks alot
Posted

You just need to go through each two digit number and convert it first to its base value thus:
if number >= 0x30 AND <= 0x39 // 0 to 9
    number -= 0x30
else if number number >= 0x41 AND <= 0x46 // A to F
    number = number - 0x41 + 10 // 10 to 15
else if number number >= 0x61 AND <= 0x66 // a to f
    number = number - 0x61 + 10 // 10 to 15

then add it to the next 4 bit portion of your destination field.
 
Share this answer
 
Split the string into sets of two characters at a time.
Integer parse at base 16 the split parts.
Convert to char.

C#
package mypackage;

public class Program {

    public static void main(String[] args) {
        final String input = "323830303030346434313461343135383538346435323462343134343535333833303339333033363030303164346330303130313031313630343031303130353165303030653038316130643164303435323236";
        final StringBuilder builder = new StringBuilder();
        for(int i = 0; i < (input.length() - 1); i += 2) {
            final String part = input.substring(i, i + 2);
            final int intValue = Integer.parseInt(part, 16); // 16 for base 16 here
            final char character = (char)intValue;
            builder.append(character);
        }
        System.out.println(builder.toString());
    }
}


Hope this helps,
Fredrik
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900