aboutsummaryrefslogtreecommitdiffstats
path: root/libdevcore
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-11-14 21:24:19 +0800
committerchriseth <c@ethdev.com>2016-11-15 06:14:10 +0800
commit2f83a4557729753d6da28eddd28d54bfc18bf5e1 (patch)
tree01b69cfe54c44eb5c29f004465434c3adbe6e75e /libdevcore
parent58e75c7a48f8166cca41e9017dad351113952ab5 (diff)
downloaddexon-solidity-2f83a4557729753d6da28eddd28d54bfc18bf5e1.tar
dexon-solidity-2f83a4557729753d6da28eddd28d54bfc18bf5e1.tar.gz
dexon-solidity-2f83a4557729753d6da28eddd28d54bfc18bf5e1.tar.bz2
dexon-solidity-2f83a4557729753d6da28eddd28d54bfc18bf5e1.tar.lz
dexon-solidity-2f83a4557729753d6da28eddd28d54bfc18bf5e1.tar.xz
dexon-solidity-2f83a4557729753d6da28eddd28d54bfc18bf5e1.tar.zst
dexon-solidity-2f83a4557729753d6da28eddd28d54bfc18bf5e1.zip
Swarm hash.
Diffstat (limited to 'libdevcore')
-rw-r--r--libdevcore/SHA3.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/libdevcore/SHA3.h b/libdevcore/SHA3.h
index c481bfc9..e3ff1335 100644
--- a/libdevcore/SHA3.h
+++ b/libdevcore/SHA3.h
@@ -53,4 +53,12 @@ inline std::string keccak256(std::string const& _input, bool _isNibbles) { retur
/// Calculate SHA3-256 MAC
inline void keccak256mac(bytesConstRef _secret, bytesConstRef _plain, bytesRef _output) { keccak256(_secret.toBytes() + _plain.toBytes()).ref().populate(_output); }
+h256 swarmHash(bytes const& _data)
+{
+ bytes size(8);
+ for (size_t i = 0; i < 8; ++i)
+ size[i] = (_data.size() >> (8 * i)) & 0xff;
+
+ return keccak256(size + _data);
+}
}