• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
CXzCrc64Hasher()20   CXzCrc64Hasher(): _crc(CRC64_INIT_VAL) {}
21 
22   MY_UNKNOWN_IMP1(IHasher)
23   INTERFACE_IHasher(;)
24 };
25 
STDMETHODIMP_(void)26 STDMETHODIMP_(void) CXzCrc64Hasher::Init() throw()
27 {
28   _crc = CRC64_INIT_VAL;
29 }
30 
STDMETHODIMP_(void)31 STDMETHODIMP_(void) CXzCrc64Hasher::Update(const void *data, UInt32 size) throw()
32 {
33   _crc = Crc64Update(_crc, data, size);
34 }
35 
STDMETHODIMP_(void)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)
43