Solidity docs say that sha256
(and sha3
, ripemd160
) arguments are tightly packed:
“tightly packed” means that the arguments are concatenated without
padding. This means that the following are all identical:
sha3("ab", "c")
sha3("abc")
sha3(0x616263)
sha3(6382179)
sha3(97, 98, 99)
Using the question's example of a = sha256(uint b, string c, bool d)
,
if we assign some values like b
is 31415, c
is "abc"
, and d
is false,
then a
would equal sha256(31415, 6382179, 0)
, which is same as sha256(0x7ab761626300)
.
For completeness, the docs mention that:
If padding is needed, explicit type conversions can be used: sha3(“x00x12”) is the same as sha3(uint16(0x12)).