public byte[] encoder(Long obj, int maxwidth) throws Exception {
if (obj == null) {
return new byte[] {};
}
if (maxwidth > 8) {
return new byte[] {};
}
long value = obj.longValue();
byte[] b = new byte[maxwidth];
for (int i = 0; i < maxwidth; i++) {
b[i] = (byte) ((value >>> ((maxwidth - 1) * 8 - i * 8)) & 0xFF);
}
return b;
}