Skip to content

Instantly share code, notes, and snippets.

@ethers
Created December 11, 2014 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethers/5a225b566393c1823524 to your computer and use it in GitHub Desktop.
Save ethers/5a225b566393c1823524 to your computer and use it in GitHub Desktop.
flipBytes Serpent
data byte[32]
def flipBytes(n):
numByte = 5
mask = 0xff
i = 0
while i < numByte:
b = n & mask
b /= 2^(i*8)
b *= 2^((numByte-i-1)*8)
mask *= 256
byte[i] = b
i += 1
ret = byte[0]
i = 1
while i < numByte:
ret = ret | byte[i]
i += 1
return(ret)
@ethers
Copy link
Author

ethers commented Dec 17, 2014

To get unsigned ints in Serpent:
map(lambda x: x%2**256, s.send(t.k0, c, 0, funid=5, abi=[]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment