All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.shoothzj.javatool.util.HexUtil Maven / Gradle / Ivy

There is a newer version: 3.1.15
Show newest version
package com.github.shoothzj.javatool.util;

import lombok.extern.slf4j.Slf4j;

/**
 * @author hezhangjian
 */
@Slf4j
public class HexUtil {

    public static byte[] hexStrToByteArray(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                    + Character.digit(s.charAt(i+1), 16));
        }
        return data;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy