How to convert hexadecimal ip address to standard ipv4 address

Hello!

I'm currently trying to convert hexadecimal ip address into A.B.C.D format.

This ip field is a string "0a0a0b43" for exemple and the result has to be 10.10.11.67
I've done some attempts but whitout success...

By advance, thanks you :slight_smile:

Hi,

There are some libraries in java which can convert hex to string and you may use that.
And then you can make a user defined function of it.
java example:

public static String convertHexToIP(String hex)
{
    String ip= "";

    for (int j = 0; j < hex.length(); j+=2) {
        String sub = hex.substring(j, j+2);
        int num = Integer.parseInt(sub, 16);
        ip += num+".";
    }

    ip = ip.substring(0, ip.length()-1);
    return ip;
}

a more generic approach is described here: https://www.mkyong.com/java/how-to-convert-hex-to-ascii-in-java/

Does this help you?

regards
Kees

1 Like

Hi Kees,

Thanks you for your quickness!
I think it will be good, i've just to find how to create and use user-defined java procedures in Neo4j

Regards
Yann

that is here:

Thanks you very much Kees!

Have a nice day :slight_smile: