-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
398 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "export_checksum.h" | ||
|
||
#include <openssl/sha.h> | ||
|
||
#include <util/string/hex.h> | ||
|
||
namespace NKikimr::NDataShard { | ||
|
||
class TSHA256 : public IExportChecksum { | ||
public: | ||
TSHA256() { | ||
SHA256_Init(&Context); | ||
} | ||
|
||
void AddData(TStringBuf data) override { | ||
SHA256_Update(&Context, data.data(), data.size()); | ||
} | ||
|
||
TString Serialize() override { | ||
unsigned char hash[SHA256_DIGEST_LENGTH]; | ||
SHA256_Final(hash, &Context); | ||
return to_lower(HexEncode(hash, SHA256_DIGEST_LENGTH)); | ||
} | ||
|
||
private: | ||
SHA256_CTX Context; | ||
}; | ||
|
||
TString ComputeExportChecksum(TStringBuf data) { | ||
IExportChecksum::TPtr checksum(CreateExportChecksum()); | ||
checksum->AddData(data); | ||
return checksum->Serialize(); | ||
} | ||
|
||
IExportChecksum* CreateExportChecksum() { | ||
return new TSHA256(); | ||
} | ||
|
||
} // NKikimr::NDataShard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <util/generic/string.h> | ||
|
||
namespace NKikimr::NDataShard { | ||
|
||
class IExportChecksum { | ||
public: | ||
using TPtr = std::unique_ptr<IExportChecksum>; | ||
|
||
virtual ~IExportChecksum() = default; | ||
|
||
virtual void AddData(TStringBuf data) = 0; | ||
virtual TString Serialize() = 0; | ||
}; | ||
|
||
IExportChecksum* CreateExportChecksum(); | ||
TString ComputeExportChecksum(TStringBuf data); | ||
|
||
} // NKikimr::NDataShard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.