Here is my bytes
array: [28,2,1994]
Now, I want to create a function that parses each value and assigns it to its own uint256
variable.
Here is an example:
uint256 day = 28;
uint256 month = 2;
uint256 year = 1994;
That said, I have a function that converts an entire bytes
array to a uint256
:
function bytesToUint(bytes memory data) private pure returns (uint256) {
require(data.length <= 32, "Invalid data length");
uint256 result = 0;
for (uint256 index = 0; index < data.length; index++) {
result = result << 8;
result += uint8(data[index]);
}
return result;
}
But I need this function to return 3 separate values that I can use in a separate function.
Any idea how to make this work?