We break files into chunks of CHUNK_SIZE(say 4MB) and write to disk using
random names. While adding more data to file we keep on updating the SHA1
(using CryptoPP::SHA1::Update() ). When the file is closed we calculate the
final digest ( using CryptoPP::SHA1::Final() ) and name the metadata file
as hash sum of contents and store the information like how many chunks,
size of each chunk, etc inside it.
If the file is modified after an offset, we are trying to make use of the
existing chunk and append new data to it, but the hash sum needs to be
computed by reading the contents of the file from beginning. If we can
serialize the sha1 object, this would save substantial time and we can
proceed further by just calling Update() with new data.
Is there easy way to serialize the SHA1 object of Crypto++?
I do not see any method(s) that allows us to both get and set m_countLo,
m_countHi, m_data and m_state. (I could locate DataBuf(), StateBuf() Init()
InitState() methods though)
Sample code:
#include <string>
#include <cryptopp/sha.h>
CryptoPP::SHA1 sha1;
byte mDigest[ CryptoPP::SHA1::DIGESTSIZE ];
byte temp[CryptoPP::SHA1::DIGESTSIZE];
std::string message1("Hello"), message2("World");
sha1.Update((byte*)message1.data(), message1.size());
//Is there any way to serialize sha1 object?
// later sha1 object is loaded and updated in some other module
sha1.Update((byte*)message2.data(), message2.size());
sha1.Final(temp);
--
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.