获取字符串定长字节码,长度不够,末位自动补0
/**
* 获取指定长的的字符串对应的16进制字节码,如果长度不够,末位自动补0
* @param srcString
* @return
*/
private byte[] getBytes(String s, int length) {
int fixLength = length - s.getBytes().length;
if (s.getBytes().length < length) {
byte[] S_bytes = new byte[length];
System.arraycopy(s.getBytes(), 0, S_bytes, 0, s.getBytes().length);
for (int x = length-fixLength; x < length; x++) {
S_bytes[x] = 0x00;
}
return S_bytes;
}
return s.getBytes();
}