Paweł Bylica
8 years ago
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
3 changed files with
5 additions and
29 deletions
-
cmake/EthDependencies.cmake
-
libdevcore/FixedHash.cpp
-
libdevcore/FixedHash.h
|
|
@ -93,7 +93,7 @@ elseif (UNIX) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
find_package(Boost 1.54.0 REQUIRED COMPONENTS random) |
|
|
|
find_package(Boost 1.54.0 REQUIRED COMPONENTS system) |
|
|
|
|
|
|
|
message(" - boost header: ${Boost_INCLUDE_DIRS}") |
|
|
|
message(" - boost lib : ${Boost_LIBRARIES}") |
|
|
|
|
|
@ -20,31 +20,9 @@ |
|
|
|
*/ |
|
|
|
|
|
|
|
#include "FixedHash.h" |
|
|
|
#include <ctime> |
|
|
|
#include <boost/algorithm/string.hpp> |
|
|
|
|
|
|
|
using namespace std; |
|
|
|
using namespace dev; |
|
|
|
|
|
|
|
boost::random_device dev::s_fixedHashEngine; |
|
|
|
|
|
|
|
h128 dev::fromUUID(std::string const& _uuid) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
return h128(boost::replace_all_copy(_uuid, "-", "")); |
|
|
|
} |
|
|
|
catch (...) |
|
|
|
{ |
|
|
|
return h128(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
std::string dev::toUUID(h128 const& _uuid) |
|
|
|
{ |
|
|
|
std::string ret = toHex(_uuid.ref()); |
|
|
|
for (unsigned i: {20, 16, 12, 8}) |
|
|
|
ret.insert(ret.begin() + i, '-'); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
std::random_device dev::s_fixedHashEngine; |
|
|
@ -26,8 +26,7 @@ |
|
|
|
#include <array> |
|
|
|
#include <cstdint> |
|
|
|
#include <algorithm> |
|
|
|
#include <boost/random/random_device.hpp> |
|
|
|
#include <boost/random/uniform_int_distribution.hpp> |
|
|
|
#include <random> |
|
|
|
#include "CommonData.h" |
|
|
|
|
|
|
|
namespace dev |
|
|
@ -37,7 +36,7 @@ namespace dev |
|
|
|
template <unsigned N> struct StaticLog2 { enum { result = 1 + StaticLog2<N/2>::result }; }; |
|
|
|
template <> struct StaticLog2<1> { enum { result = 0 }; }; |
|
|
|
|
|
|
|
extern boost::random_device s_fixedHashEngine; |
|
|
|
extern std::random_device s_fixedHashEngine; |
|
|
|
|
|
|
|
/// Fixed-size raw-byte array container type, with an API optimised for storing hashes.
|
|
|
|
/// Transparently converts to/from the corresponding arithmetic type; this will
|
|
|
@ -154,7 +153,7 @@ public: |
|
|
|
void randomize(Engine& _eng) |
|
|
|
{ |
|
|
|
for (auto& i: m_data) |
|
|
|
i = (uint8_t)boost::random::uniform_int_distribution<uint16_t>(0, 255)(_eng); |
|
|
|
i = (uint8_t)std::uniform_int_distribution<uint16_t>(0, 255)(_eng); |
|
|
|
} |
|
|
|
|
|
|
|
/// @returns a random valued object.
|
|
|
@ -291,7 +290,6 @@ public: |
|
|
|
bytesConstRef ref() const { return FixedHash<T>::ref(); } |
|
|
|
byte const* data() const { return FixedHash<T>::data(); } |
|
|
|
|
|
|
|
static SecureFixedHash<T> random() { SecureFixedHash<T> ret; ret.randomize(s_fixedHashEngine); return ret; } |
|
|
|
using FixedHash<T>::firstBitSet; |
|
|
|
|
|
|
|
void clear() { ref().cleanse(); } |
|
|
|