public static String dnsEncode(String name) throws IOException {
        String[] parts = name.split("\\.");

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        for (String part : parts) {
            byte[] bytes = toUtf8Bytes("_" + normalise(part));
            if (bytes == null) {
                break;
            }
            bytes[0] = (byte) (bytes.length - 1);

            outputStream.write(bytes);
        }

        return Numeric.toHexString(outputStream.toByteArray()) + "00";
    }
@Test
    void testDnsEncode() throws IOException {
        String dnsEncoded = NameHash.dnsEncode("1.offchainexample.eth");
        assertEquals("0x01310f6f6666636861696e6578616d706c650365746800", dnsEncoded);
    }