47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
/* Copyright 2015, Michele Santullo
|
|
* This file is part of DoorKeeper.
|
|
*
|
|
* DoorKeeper is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* DoorKeeper is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with DoorKeeper. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "doorkeeper/helpers/typename.hpp"
|
|
#include "tiger.h"
|
|
|
|
namespace dk {
|
|
namespace {
|
|
enum {
|
|
TigerPaddingV2 = 0x80,
|
|
TigerPaddingV1 = 0x01
|
|
};
|
|
} //unnamed namespace
|
|
|
|
namespace implem {
|
|
HashType hash_string (const char* parString, std::size_t parLen) {
|
|
t_res retval;
|
|
|
|
::tiger(parString, parLen, retval, TigerPaddingV2);
|
|
|
|
HashType hash{retval[0], retval[1], retval[2]};
|
|
return hash;
|
|
}
|
|
} //namespace implem
|
|
|
|
bool operator< (const HashType& parL, const HashType& parR) {
|
|
return parL.a < parR.a or
|
|
(parL.a == parR.a and parL.b < parR.b) or
|
|
(parL.a == parR.a and parL.b == parR.b and parL.c < parR.c)
|
|
;
|
|
}
|
|
} //namespace dk
|