2011-11-04 16:56:25 +11:00
|
|
|
/*
|
2018-08-04 15:14:06 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2011-11-04 16:56:25 +11:00
|
|
|
*
|
2018-01-13 13:48:58 +11:00
|
|
|
* Copyright 2010-2018 Danny Robson <danny@nerdcruft.net>
|
2011-11-04 16:56:25 +11:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "bsdsum.hpp"
|
|
|
|
|
2018-01-13 13:48:58 +11:00
|
|
|
#include "../bitwise.hpp"
|
2011-11-04 16:56:25 +11:00
|
|
|
|
2018-08-05 14:42:02 +10:00
|
|
|
using cruft::hash::bsdsum;
|
2016-06-20 16:38:57 +10:00
|
|
|
|
2016-06-17 15:46:11 +10:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2018-01-13 13:48:58 +11:00
|
|
|
typename bsdsum::digest_t
|
2018-08-05 14:42:02 +10:00
|
|
|
bsdsum::operator() (cruft::view<const uint8_t*> data) const noexcept
|
2016-06-20 16:38:57 +10:00
|
|
|
{
|
2018-01-13 13:48:58 +11:00
|
|
|
digest_t accum = 0;
|
2011-11-04 16:56:25 +11:00
|
|
|
|
2018-01-13 13:48:58 +11:00
|
|
|
for (const auto i: data)
|
2018-08-05 14:42:02 +10:00
|
|
|
accum = cruft::rotater (accum, 1) + i;
|
2016-06-17 15:46:11 +10:00
|
|
|
|
2018-01-13 13:48:58 +11:00
|
|
|
return accum;
|
2016-06-17 15:46:11 +10:00
|
|
|
}
|