dagger-contracts/contracts/Endian.sol

15 lines
413 B
Solidity
Raw Normal View History

// SPDX-License-Identifier: MIT
2024-01-23 09:24:02 +00:00
pragma solidity 0.8.23;
contract Endian {
/// reverses byte order to allow conversion between little endian and big
/// endian integers
function _byteSwap(bytes32 input) internal pure returns (bytes32 output) {
output = output | bytes1(input);
for (uint i = 1; i < 32; i++) {
output = output >> 8;
output = output | bytes1(input << (i * 8));
}
}
}