mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
.
This commit is contained in:
@ -43,8 +43,14 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
//result = crypt_file.EncryptOfficeFile(srcFileName, dstFileName, password, L"123456789");
|
||||
//result = crypt_file.DecryptOfficeFile(dstFileName, dstFileName2, password, bDataIntegrity);
|
||||
|
||||
std::wstring addit_name = NSFile::CFileBinary::CreateTempFileWithUniqueName(L"", L"asd");
|
||||
std::string addit_info = "11111111111111111111111111111";
|
||||
crypt_file.WriteAdditional(srcFileName, addit_name.substr(1), addit_info);
|
||||
std::wstring addit_name = L"11111111111111111111111111111";
|
||||
|
||||
std::string addit_info = crypt_file.ReadAdditional(srcFileName, addit_name);
|
||||
|
||||
std::wstring temp = NSFile::CFileBinary::CreateTempFileWithUniqueName(L"", L"asd");
|
||||
|
||||
addit_info += std::string(temp.begin(), temp.end());
|
||||
|
||||
crypt_file.WriteAdditional(srcFileName, addit_name, addit_info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -977,6 +977,33 @@ bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const s
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string ECMACryptFile::ReadAdditional(const std::wstring &file_name, const std::wstring &addit_name)
|
||||
{
|
||||
POLE::Storage *pStorage = new POLE::Storage(file_name.c_str());
|
||||
|
||||
if (!pStorage->open(false, false))
|
||||
{
|
||||
delete pStorage;
|
||||
return "";
|
||||
}
|
||||
std::string result;
|
||||
POLE::Stream *pStream = new POLE::Stream(pStorage, addit_name);
|
||||
if ((pStream) && (pStream->size() > 0))
|
||||
{
|
||||
_UINT64 lengthData, size = pStream->size();
|
||||
|
||||
char* data = new char[size];
|
||||
|
||||
lengthData = pStream->read((unsigned char*)data, size);
|
||||
|
||||
result = std::string(data, lengthData);
|
||||
delete []data;
|
||||
delete pStream;
|
||||
}
|
||||
delete pStorage;
|
||||
|
||||
return result;
|
||||
}
|
||||
bool ECMACryptFile::WriteAdditional(const std::wstring &file_name, const std::wstring &addit_name, const std::string &addit_info)
|
||||
{
|
||||
POLE::Storage *pStorage = new POLE::Storage(file_name.c_str());
|
||||
@ -992,6 +1019,7 @@ bool ECMACryptFile::WriteAdditional(const std::wstring &file_name, const std::ws
|
||||
POLE::Stream *pStream = new POLE::Stream(pStorage, addit_name, true, addit_info.size());
|
||||
|
||||
pStream->write((unsigned char*)addit_info.c_str(), addit_info.size());
|
||||
pStream->setSize(addit_info.size());
|
||||
|
||||
pStream->flush();
|
||||
delete pStream;
|
||||
|
||||
@ -40,7 +40,9 @@ public:
|
||||
bool DecryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, bool & bDataIntegrity);
|
||||
bool EncryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, const std::wstring &documentID = L"");
|
||||
|
||||
std::string ReadAdditional(const std::wstring &file_name, const std::wstring &addit_name);
|
||||
bool WriteAdditional(const std::wstring &file_name, const std::wstring &addit_name, const std::string &addit_info);
|
||||
|
||||
struct _refComponent
|
||||
{
|
||||
int type;
|
||||
@ -51,5 +53,5 @@ public:
|
||||
std::vector<_refComponent> refComponents;
|
||||
std::wstring dataSpaceName;
|
||||
};
|
||||
std::vector<_mapEntry> mapEntries;
|
||||
std::vector<_mapEntry> mapEntries;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user