Pads and packs the given byte array to a specified maximum size and appends its length.
This function ensures that the byte array does not exceed the maximum size, throwing an error if it does.
It is useful for preparing byte data for further processing or transmission by ensuring a consistent format.
Parameters
bytes: Uint8Array
The byte array to be padded and packed.
maxSizeBytes: number
The maximum allowed size for the byte array.
Returns bigint[]
A new Uint8Array that contains the padded and packed bytes along with the length of the original byte array.
Throws
Error if the length of the input bytes exceeds the maximum size.
Pads and packs the given byte array to a specified maximum size and appends its length. This function ensures that the byte array does not exceed the maximum size, throwing an error if it does. It is useful for preparing byte data for further processing or transmission by ensuring a consistent format.