mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: C++-ify SHA1 interface
All callers of the SHA1 code are C++. Might just as well use a C++ like interface. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
729356e0b1
commit
21f68387ae
6 changed files with 71 additions and 78 deletions
|
@ -135,9 +135,6 @@ std::string normalize_cloud_name(const std::string &remote_in)
|
|||
|
||||
std::string get_local_dir(const std::string &url, const std::string &branch)
|
||||
{
|
||||
SHA_CTX ctx;
|
||||
unsigned char hash[20];
|
||||
|
||||
// this optimization could in theory lead to odd things happening if the
|
||||
// cloud backend servers ever get out of sync - but when a user switches
|
||||
// between those servers (either because one is down, or because the algorithm
|
||||
|
@ -148,11 +145,11 @@ std::string get_local_dir(const std::string &url, const std::string &branch)
|
|||
|
||||
// That zero-byte update is so that we don't get hash
|
||||
// collisions for "repo1 branch" vs "repo 1branch".
|
||||
SHA1_Init(&ctx);
|
||||
SHA1_Update(&ctx, remote.c_str(), remote.size());
|
||||
SHA1_Update(&ctx, "", 1);
|
||||
SHA1_Update(&ctx, branch.c_str(), branch.size());
|
||||
SHA1_Final(hash, &ctx);
|
||||
SHA1 sha;
|
||||
sha.update(remote);
|
||||
sha.update("", 1);
|
||||
sha.update(branch);
|
||||
auto hash = sha.hash();
|
||||
return format_string_std("%s/cloudstorage/%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||
system_default_directory(),
|
||||
hash[0], hash[1], hash[2], hash[3],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue