Skip to content
Snippets Groups Projects
Commit 9b45eabb authored by Adrien Béraud's avatar Adrien Béraud
Browse files

infohash: remove std::hash

InfoHash is an hash itself, std::hash reduces the precision,
could cause potential security issues or bugs.
parent 6e0e63c3
Branches
Tags
No related merge requests found
...@@ -198,22 +198,3 @@ public: ...@@ -198,22 +198,3 @@ public:
}; };
} }
namespace std
{
template<>
struct hash<dht::InfoHash>
{
typedef dht::InfoHash argument_type;
typedef std::size_t result_type;
result_type operator()(dht::InfoHash const& s) const
{
result_type r {};
std::hash<uint8_t> hash_fn;
for (size_t i = 0; i < HASH_LEN; i++)
r = r ^ (hash_fn(s[i]) << i*4);
return r;
}
};
}
...@@ -84,9 +84,6 @@ cdef class InfoHash(_WithID): ...@@ -84,9 +84,6 @@ cdef class InfoHash(_WithID):
if op == 2: if op == 2:
return self._infohash == other._infohash return self._infohash == other._infohash
return NotImplemented return NotImplemented
def __hash__(self):
cdef cpp.hash[cpp.InfoHash] hash_fn
return hash_fn.get(self._infohash)
def getBit(InfoHash self, bit): def getBit(InfoHash self, bit):
return self._infohash.getBit(bit) return self._infohash.getBit(bit)
def setBit(InfoHash self, bit, b): def setBit(InfoHash self, bit, b):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment