Skip to content

Commit c5bf6c2

Browse files
committed
add hardcoded instance types
1 parent d8929c0 commit c5bf6c2

File tree

4 files changed

+3746
-1
lines changed

4 files changed

+3746
-1
lines changed

core/include/huaweicloud/core/utils/Hasher.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ class HUAWEICLOUD_CORE_EXPORT Hasher {
3434
std::string hexEncode(const unsigned char *md, size_t length) const;
3535
int hashSHA256(const std::string &str, unsigned char *hash, int i);
3636
std::vector<unsigned char> hmac(const void *key, unsigned int keyLength, const std::string &data);
37+
int hashstring(const char* strTohash);
3738
};
3839
}
3940
}
4041
}
4142
}
42-
#endif // HUAWEICLOUD_SDK_CORE_UTILS_HASHER_H
43+
#endif // HUAWEICLOUD_SDK_CORE_UTILS_HASHER_H

core/src/utils/Hasher.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,17 @@ std::vector<unsigned char> Hasher::hmac(const void *key, unsigned int keyLength,
7373
strlen(charData.data()), md.data(), &mdLength);
7474
return md;
7575
}
76+
77+
int Hasher::hashstring(const char* strTohash)
78+
{
79+
if (!strTohash)
80+
return 0;
81+
82+
unsigned hash = 0;
83+
while (char charValue = *strTohash++)
84+
{
85+
hash = charValue + 31 * hash;
86+
}
87+
88+
return hash;
89+
}

0 commit comments

Comments
 (0)