Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hardcoded instance types #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/include/huaweicloud/core/utils/Hasher.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ class HUAWEICLOUD_CORE_EXPORT Hasher {
std::string hexEncode(const unsigned char *md, size_t length) const;
int hashSHA256(const std::string &str, unsigned char *hash, int i);
std::vector<unsigned char> hmac(const void *key, unsigned int keyLength, const std::string &data);
static int hashstring(const char* strTohash);
};
}
}
}
}
#endif // HUAWEICLOUD_SDK_CORE_UTILS_HASHER_H
#endif // HUAWEICLOUD_SDK_CORE_UTILS_HASHER_H
14 changes: 14 additions & 0 deletions core/src/utils/Hasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,17 @@ std::vector<unsigned char> Hasher::hmac(const void *key, unsigned int keyLength,
strlen(charData.data()), md.data(), &mdLength);
return md;
}

int Hasher::hashstring(const char* strTohash)
{
if (!strTohash)
return 0;

unsigned hash = 0;
while (char charValue = *strTohash++)
{
hash = charValue + 31 * hash;
}

return hash;
}
Loading