blob: 8cfcd4d0bbea422433a12a3250b3baa1d3700f92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Span.h>
#include <AK/Types.h>
#include <LibCrypto/Checksum/Adler32.h>
namespace Crypto::Checksum {
void Adler32::update(ReadonlyBytes data)
{
for (size_t i = 0; i < data.size(); i++) {
m_state_a = (m_state_a + data.at(i)) % 65521;
m_state_b = (m_state_b + m_state_a) % 65521;
}
};
u32 Adler32::digest()
{
return (m_state_b << 16) | m_state_a;
}
}
|