Java tutorial
//package com.java2s; public class Main { public static byte[] StringToHexBytes(int length, String string) { byte[] data = new byte[length]; byte[] strByte = string.getBytes(); for (int i = 0; i < strByte.length; i++) { data[i] = strByte[i]; } return data; } }