diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/Common/XzCrc64Reg.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/CPP/Common/XzCrc64Reg.cpp b/CPP/Common/XzCrc64Reg.cpp new file mode 100644 index 0000000..33b5249 --- /dev/null +++ b/CPP/Common/XzCrc64Reg.cpp | |||
@@ -0,0 +1,42 @@ | |||
1 | // XzCrc64Reg.cpp | ||
2 | |||
3 | #include "StdAfx.h" | ||
4 | |||
5 | #include "../../C/CpuArch.h" | ||
6 | #include "../../C/XzCrc64.h" | ||
7 | |||
8 | #include "../Common/MyCom.h" | ||
9 | |||
10 | #include "../7zip/Common/RegisterCodec.h" | ||
11 | |||
12 | class CXzCrc64Hasher: | ||
13 | public IHasher, | ||
14 | public CMyUnknownImp | ||
15 | { | ||
16 | UInt64 _crc; | ||
17 | Byte mtDummy[1 << 7]; | ||
18 | |||
19 | public: | ||
20 | CXzCrc64Hasher(): _crc(CRC64_INIT_VAL) {} | ||
21 | |||
22 | MY_UNKNOWN_IMP1(IHasher) | ||
23 | INTERFACE_IHasher(;) | ||
24 | }; | ||
25 | |||
26 | STDMETHODIMP_(void) CXzCrc64Hasher::Init() throw() | ||
27 | { | ||
28 | _crc = CRC64_INIT_VAL; | ||
29 | } | ||
30 | |||
31 | STDMETHODIMP_(void) CXzCrc64Hasher::Update(const void *data, UInt32 size) throw() | ||
32 | { | ||
33 | _crc = Crc64Update(_crc, data, size); | ||
34 | } | ||
35 | |||
36 | STDMETHODIMP_(void) CXzCrc64Hasher::Final(Byte *digest) throw() | ||
37 | { | ||
38 | UInt64 val = CRC64_GET_DIGEST(_crc); | ||
39 | SetUi64(digest, val); | ||
40 | } | ||
41 | |||
42 | REGISTER_HASHER(CXzCrc64Hasher, 0x4, "CRC64", 8) | ||