Skip to content

Instantly share code, notes, and snippets.

Created January 17, 2018 21:05
Show Gist options
  • Save anonymous/214617dfdfd93f4a589472530c70b21b to your computer and use it in GitHub Desktop.
Save anonymous/214617dfdfd93f4a589472530c70b21b to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
pragma solidity ^0.4.19;
contract FlipEndian {
function flip32_1(bytes32 a) public constant returns (bytes32 b){
assembly {
0
and(div(a, 0x100000000000000000000000000000000000000000000000000000000000000), 0xFF)
or
and(div(a, 0x10000000000000000000000000000000000000000000000000000000000), 0xFF00)
or
and(div(a, 0x1000000000000000000000000000000000000000000000000000000), 0xFF0000)
or
and(div(a, 0x100000000000000000000000000000000000000000000000000), 0xFF000000)
or
and(div(a, 0x10000000000000000000000000000000000000000000000), 0xFF00000000)
or
and(div(a, 0x1000000000000000000000000000000000000000000), 0xFF0000000000)
or
and(div(a, 0x100000000000000000000000000000000000000), 0xFF000000000000)
or
and(div(a, 0x10000000000000000000000000000000000), 0xFF00000000000000)
or
and(div(a, 0x1000000000000000000000000000000), 0xFF0000000000000000)
or
and(div(a, 0x100000000000000000000000000), 0xFF000000000000000000)
or
and(div(a, 0x10000000000000000000000), 0xFF00000000000000000000)
or
and(div(a, 0x1000000000000000000), 0xFF0000000000000000000000)
or
and(div(a, 0x100000000000000), 0xFF000000000000000000000000)
or
and(div(a, 0x10000000000), 0xFF00000000000000000000000000)
or
and(div(a, 0x1000000), 0xFF0000000000000000000000000000)
or
and(div(a, 0x100), 0xFF000000000000000000000000000000)
or
=: b
a := mul(a, 0x100000000000000000000000000000000)
0
and(div(a, 0x100000000000000000000000000000000000000000000000000000000000000), 0xFF)
or
and(div(a, 0x10000000000000000000000000000000000000000000000000000000000), 0xFF00)
or
and(div(a, 0x1000000000000000000000000000000000000000000000000000000), 0xFF0000)
or
and(div(a, 0x100000000000000000000000000000000000000000000000000), 0xFF000000)
or
and(div(a, 0x10000000000000000000000000000000000000000000000), 0xFF00000000)
or
and(div(a, 0x1000000000000000000000000000000000000000000), 0xFF0000000000)
or
and(div(a, 0x100000000000000000000000000000000000000), 0xFF000000000000)
or
and(div(a, 0x10000000000000000000000000000000000), 0xFF00000000000000)
or
and(div(a, 0x1000000000000000000000000000000), 0xFF0000000000000000)
or
and(div(a, 0x100000000000000000000000000), 0xFF000000000000000000)
or
and(div(a, 0x10000000000000000000000), 0xFF00000000000000000000)
or
and(div(a, 0x1000000000000000000), 0xFF0000000000000000000000)
or
and(div(a, 0x100000000000000), 0xFF000000000000000000000000)
or
and(div(a, 0x10000000000), 0xFF00000000000000000000000000)
or
and(div(a, 0x1000000), 0xFF0000000000000000000000000000)
or
and(div(a, 0x100), 0xFF000000000000000000000000000000)
or
and(div(a, 0x1), 0xFF000000000000000000000000000000)
or
0x100000000000000000000000000000000
mul
b
or
=: b
}
return b;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment