| 10 | namespace tera { |
| 11 | |
| 12 | int32_t GetHashString(const std::string& str, uint32_t seed, std::string* result) { |
| 13 | if (result == NULL) { |
| 14 | return -1; |
| 15 | } |
| 16 | uint32_t hash = 0; |
| 17 | if (GetHashNumber(str, seed, &hash) != 0) { |
| 18 | return -1; |
| 19 | } |
| 20 | char hash_str[9]; |
| 21 | sprintf(hash_str, "%08x", hash); |
| 22 | |
| 23 | result->assign(hash_str, 8); |
| 24 | return 0; |
| 25 | } |
| 26 | |
| 27 | int32_t GetHashNumber(const std::string& str, uint32_t seed, uint32_t* result) { |
| 28 | const char* data = str.c_str(); |
no test coverage detected