/* */ #ifndef _D_XOR_CLOSER_H_ #define _D_XOR_CLOSER_H_ #include namespace aria2 { class XORCloser { private: const unsigned char* _key; size_t _length; public: XORCloser(const unsigned char* key, size_t length):_key(key), _length(length) {} bool operator()(const unsigned char* key1, const unsigned char* key2) const { for(size_t i = 0; i < _length; ++i) { unsigned char c1 = _key[i]^key1[i]; unsigned char c2 = _key[i]^key2[i]; if(c1 < c2) { return true; } else if(c1 > c2) { return false; } } return true; } }; } // namespace aria2 #endif // _D_XOR_CLOSER_H_