Hi Guys ,
How can i change the 5th and 6th byte from this bytes8 0x3FcB875f"0000"ddC4,or just arrive at this solution where:
last four bytes(of bytes8) are this way 0x********"0000ddC4" and the first four bytes(of bytes8) can have any number but !=0 ?
bytes8 normal=0x3FcB875f56beddC4
// POSSIBLE SOLUTION //
bytes8 conver=0x3FcB875f0000ddC4
bytes8 anothe=0x****0000ddC4
Where 1 ore more of * is != 0
bytes8 another example solution=*0x000100100000ddC4*
bytes8 another example solution=*0x00a10f000000ddC4*
This is what i try:
bytes8 txOriginBytes8= 0x3FcB875f56beddC4;
// original 8bytes 0x3FcB875f56beddC4
bytes2 twoBytes= bytes2(uint16(uint64(txOriginBytes8)));
// take last two bytes: 0xddC4
bytes4 fourBytes=twoBytes;
// add to a four bytes array: 0xddC40000
bytes4 shiftTwoBytes=fourBytes >> 16;
// shifting right by two bytes 0x0000ddC4
bytes8 toEithBytes=bytes8(uint64(uint32(shiftTwoBytes)));
// put in a bytes8 array 0x000000000000ddc4
return toEithBytes;