1 // Sha256Reg.cpp 2 3 #include "StdAfx.h" 4 5 #include "../../C/Sha256.h" 6 7 #include "../Common/MyCom.h" 8 9 #include "../7zip/Common/RegisterCodec.h" 10 11 class CSha256Hasher: 12 public IHasher, 13 public CMyUnknownImp 14 { 15 CSha256 _sha; 16 Byte mtDummy[1 << 7]; 17 18 public: CSha256Hasher()19 CSha256Hasher() { Sha256_Init(&_sha); } 20 21 MY_UNKNOWN_IMP1(IHasher) 22 INTERFACE_IHasher(;) 23 }; 24 STDMETHODIMP_(void)25STDMETHODIMP_(void) CSha256Hasher::Init() throw() 26 { 27 Sha256_Init(&_sha); 28 } 29 STDMETHODIMP_(void)30STDMETHODIMP_(void) CSha256Hasher::Update(const void *data, UInt32 size) throw() 31 { 32 Sha256_Update(&_sha, (const Byte *)data, size); 33 } 34 STDMETHODIMP_(void)35STDMETHODIMP_(void) CSha256Hasher::Final(Byte *digest) throw() 36 { 37 Sha256_Final(&_sha, digest); 38 } 39 40 REGISTER_HASHER(CSha256Hasher, 0xA, "SHA256", SHA256_DIGEST_SIZE) 41