xref: /aosp_15_r20/external/lzma/CPP/Common/Md5Reg.cpp (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // Md5Reg.cpp
2 
3 #include "StdAfx.h"
4 
5 #include "../../C/Md5.h"
6 
7 #include "../Common/MyBuffer2.h"
8 #include "../Common/MyCom.h"
9 
10 #include "../7zip/Common/RegisterCodec.h"
11 
12 Z7_CLASS_IMP_COM_1(
13   CMd5Hasher
14   , IHasher
15 )
16   CAlignedBuffer1 _buf;
17 public:
18   Byte _mtDummy[1 << 7];
19 
20   CMd5 *Md5() { return (CMd5 *)(void *)(Byte *)_buf; }
21 public:
22   CMd5Hasher():
23     _buf(sizeof(CMd5))
24   {
25     Md5_Init(Md5());
26   }
27 };
28 
29 Z7_COM7F_IMF2(void, CMd5Hasher::Init())
30 {
31   Md5_Init(Md5());
32 }
33 
34 Z7_COM7F_IMF2(void, CMd5Hasher::Update(const void *data, UInt32 size))
35 {
36   Md5_Update(Md5(), (const Byte *)data, size);
37 }
38 
39 Z7_COM7F_IMF2(void, CMd5Hasher::Final(Byte *digest))
40 {
41   Md5_Final(Md5(), digest);
42 }
43 
44 REGISTER_HASHER(CMd5Hasher, 0x208, "MD5", MD5_DIGEST_SIZE)
45