I am working with large 32 bit numbers. I need to convert these numbers to byte format and write them to an array of bytes. For example, the number 434729217 will be stored in a byte array as [25,-23,113,1]. But also among large 32 bit numbers there can be zeros, and they will already be stored as [0], but I need everything to be fixed and they are stored as [0,0,0,0]. How can this be implemented?
I tried like this, but the numbers are still not written the way I would like
byte[] byteArray = new byte[4];
List<byte[]> byteList = new ArrayList<>();
byteArray = encrypt.toByteArray(); //encrypt is bigint 32 bit number
byteList.add(byteArray)
This is how bytes are stored