if(hex == null) {
throw new ScriptusRuntimeException("hex string should not be null");
}
if (hex.length() % 2 == 1) {
RuntimeException e = new ScriptusRuntimeException("Hex.length="+hex.length());
e.printStackTrace();
throw e;
}
if(expectedLength != -1 && hex.length() / 2 != expectedLength) {
throw new ScriptusRuntimeException("Expected "+expectedLength+" bytes, got "+hex.length() / 2);
}